hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.27k stars 225 forks source link

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

Closed bluetarpmedia closed 6 months ago

bluetarpmedia commented 6 months ago

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