Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] MSVC (C++20) emits a warning when compiling lowered Cpp1 after using Cppfront with -include-std #929

Closed
bluetarpmedia opened this issue Jan 11, 2024 · 0 comments · Fixed by #930
Labels
bug Something isn't working

Comments

@bluetarpmedia
Copy link
Contributor

Describe the bug
In C++20 mode, MSVC reports an STL4038 warning regarding <stdfloat> when compiling Cpp1 code that was generated by Cppfront with the -include-std flag.

To Reproduce
Run Cppfront with the -in or -include-std flag on this code:

main: () -> int = {
    return 0;
}

Then compile the result with MSVC with /std:c++20.

See here on Godbolt.

This warning is emitted:

stdfloat(12): warning STL4038: The contents of <stdfloat> are available only with C++23 or later.

Additional context
In cpp2util.h the test for including <stdfloat> is:

#if __has_include(<stdfloat>)

This returns true even when building for C++20 with MSVC, and the <stdfloat> header contains this:

#if !_HAS_CXX23
_EMIT_STL_WARNING(STL4038, "The contents of <stdfloat> are available only with C++23 or later.");
#else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv
@bluetarpmedia bluetarpmedia added the bug Something isn't working label Jan 11, 2024
bluetarpmedia added a commit to bluetarpmedia/cppfront that referenced this issue Jan 11, 2024
The __has_include test for <stdfloat> returns true even in C++20 because the file exists, but the stdfloat header emits an error when not compiled with C++23.

Fixes hsutter#929
hsutter pushed a commit that referenced this issue Jan 16, 2024
…ng (#930)

* Only #include <stdfloat> on MSVC when in C++23 mode to remove a warning

The __has_include test for <stdfloat> returns true even in C++20 because the file exists, but the stdfloat header emits an error when not compiled with C++23.

Fixes #929

* Simplified condition for #including <stdfloat> thanks to gregmarr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant