Skip to content

[Impeller] Fix Windows build with MSVC 14.52: std::modf is [[nodiscard]] - #193413

Merged
auto-submit[bot] merged 13 commits into
flutter:masterfrom
Gustl22:fix-msvc-14.52-modf-nodiscard
Nov 24, 2026
Merged

auto-submit[bot] merged 13 commits into
flutter:masterfrom
Gustl22:fix-msvc-14.52-modf-nodiscard

Conversation

@Gustl22

@Gustl22 Gustl22 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

The MSVC 14.52 STL declares std::modf as [[nodiscard]] (14.51 does not). RoundToHalf in line_geometry.cc called std::modf only for its integral part output parameter and discarded the return value, which breaks the Windows engine build because warnings are treated as errors:

../../flutter/impeller/entity/geometry/line_geometry.cc(86,3): error: ignoring return value of function declared with 'nodiscard' attribute [-Werror,-Wunused-result]
   86 |   std::modf(x, &whole);
      |   ^~~~~~~~~~~~~~~~~~~~

Use std::trunc instead, which returns the integral part directly and yields the same value as std::modf's integral part for all inputs, including infinities and NaN.

Related to #96138.

For transparency: This PR was partially created with help of Claude.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

The MSVC 14.52 STL declares std::modf as [[nodiscard]] (14.51 does not).
RoundToHalf in line_geometry.cc called std::modf only for its integral
part output parameter and discarded the return value, which breaks the
Windows engine build because warnings are treated as errors:

    ../../flutter/impeller/entity/geometry/line_geometry.cc(86,3): error: ignoring return value of function declared with 'nodiscard' attribute [-Werror,-Wunused-result]
       86 |   std::modf(x, &whole);
          |   ^~~~~~~~~~~~~~~~~~~~

Use std::trunc instead, which returns the integral part directly and
yields the same value as std::modf's integral part for all inputs,
including infinities and NaN.

Related to flutter#96138.
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Sep 27, 2026
@Gustl22

Gustl22 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

This PR is maybe test exempt as I did not change any logic. It could be tested by just running the pipeline in VS 2026, but it still needs the CIPD package for that.

See #96138
See https://discord.com/channels/608014603317936148/1547949496326160395

@Gustl22
Gustl22 marked this pull request as ready for review October 22, 2026 05:27
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If both you and the PR author believe this PR qualifies for a test exemption, escalate to the tech lead for the changed area to review and apply the test-exempt label. All reviewers should feel empowered to ask for tests before escalating.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the RoundToHalf function in line_geometry.cc by replacing std::modf with std::trunc. Feedback suggests casting the literal 0.5 to Scalar to prevent implicit double promotion during the addition operation.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Gustl22

Gustl22 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@loic-sharma I hope it’s not too presumptuous of me to ask, if you could have a look at this mini-PR? The main reason is #191560

Thx for your time.

@jmagman jmagman added platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team labels Nov 4, 2026
@github-actions github-actions Bot removed platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team labels Nov 7, 2026
@Gustl22

Gustl22 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@jmagman would you mind adding the labels again, so they appear in triage again? They were removed when merging from master. Thx :D

@Piinks
Piinks requested a review from a team November 18, 2026 21:21
@Piinks Piinks added the team-windows Owned by the Windows platform team label Nov 18, 2026
@github-actions github-actions Bot removed the team-windows Owned by the Windows platform team label Nov 23, 2026
@Gustl22

Gustl22 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@mattkae could you help me out on the review? Would really appreciate it.

And also, do you know how this can potentially be enforced by using CIPD with VS26?

@loic-sharma

loic-sharma commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

FYI, this PR is in Impeller and should be reviewed by the engine team. Please don't apply the team-windows label as this removes the PR from the engine team's triage queue :)

@loic-sharma loic-sharma added the CICD Run CI/CD label Nov 23, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but this will need a second review + test exemption from the engine team

@gaaclarke

Copy link
Copy Markdown
Member

test exempt: no logic change, just switching APIs

@gaaclarke gaaclarke added test-exempt Exempt from tests. Overrides `missing-tests` label autosubmit Merge PR when tree becomes green via auto submit App labels Nov 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into flutter:master with commit 6ded132 Nov 24, 2026
26 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@Gustl22
Gustl22 deleted the fix-msvc-14.52-modf-nodiscard branch November 24, 2026 06:02
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 24, 2026
flutter/flutter@98744d3...b75c5b3

2026-11-24 [email protected] Roll Skia from 89e364b13f05 to 2140958ee284 (3 revisions) (flutter/flutter#197287)
2026-11-24 [email protected] Roll Skia from f82f3efc0461 to 89e364b13f05 (6 revisions) (flutter/flutter#197284)
2026-11-24 [email protected] Roll Dart SDK from 10aef26c73f5 to 87f515c52de9 (1 revision) (flutter/flutter#197279)
2026-11-24 [email protected] iOS: Drive platform view tests through IOSExternalViewEmbedder (flutter/flutter#197263)
2026-11-24 [email protected] Fix null check crash in flushSemantics from a stale ancestor geometry cache (flutter/flutter#192724)
2026-11-24 [email protected] [Impeller] Fix Windows build with MSVC 14.52: std::modf is [[nodiscard]] (flutter/flutter#193413)
2026-11-24 [email protected] [web] Preserve fill rules from path operations (flutter/flutter#195971)
2026-11-24 [email protected] Regenerate tool_test_durations.json (flutter/flutter#197261)
2026-11-24 [email protected] Roll Skia from 694af434cadd to f82f3efc0461 (4 revisions) (flutter/flutter#197258)
2026-11-24 [email protected] Increase number of 'Linux tool_integration_tests' subshards (flutter/flutter#197262)
2026-11-24 [email protected] Run tool_integration_tests app tests in one subshard instead of all of them (flutter/flutter#197264)
2026-11-24 [email protected] [flutter_tools] Pass featureFlags in localizations_test.dart (flutter/flutter#197269)
2026-11-23 [email protected] Fix Orca flat review in Linux accessibility (flutter/flutter#196338)
2026-11-23 [email protected] [flutter tools] Pass --client-id=flutter-analyze to the analysis server (flutter/flutter#197227)
2026-11-23 [email protected] [Flutter GPU] Expose the maximum render target size (flutter/flutter#196640)
2026-11-23 [email protected] iOS: Don't clear raster thread state in platform views reset (flutter/flutter#197025)
2026-11-23 [email protected] iOS: Composite platform views from layers in tests (flutter/flutter#197021)
2026-11-23 [email protected] [flutter_tools] Harden extension diagnostics models and RPC failure handling (flutter/flutter#196233)
2026-11-23 [email protected] [flutter_tools] Support standalone UI packages in gen-l10n (flutter/flutter#194500)
2026-11-23 [email protected] [flutter_tools] Consolidate ToolDependencies.bootstrap builders and require extension managers (flutter/flutter#196388)
2026-11-23 [email protected] Roll Skia from 31b19bdc8195 to 694af434cadd (2 revisions) (flutter/flutter#197239)
2026-11-23 [email protected] Roll Dart SDK from df632229552e to 10aef26c73f5 (1 revision) (flutter/flutter#197234)
2026-11-23 [email protected] [macOS] Fix back buffer cache returning a wrong-size surface (Impeller null deref in Canvas::SetupRenderPass) (flutter/flutter#192522)
2026-11-23 [email protected] Add Settings::frame_built_callback for UI frame build timings (flutter/flutter#197213)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. missing-tests test-exempt Exempt from tests. Overrides `missing-tests` label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants