Skip to content

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

Draft
Gustl22 wants to merge 3 commits into
flutter:masterfrom
Gustl22:fix-msvc-14.52-modf-nodiscard
Draft

Gustl22 wants to merge 3 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant