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

Do not #undef __STRICT_ANSI__ #2059

Closed
jwakely opened this issue Dec 10, 2020 · 3 comments
Closed

Do not #undef __STRICT_ANSI__ #2059

jwakely opened this issue Dec 10, 2020 · 3 comments

Comments

@jwakely
Copy link
Contributor

jwakely commented Dec 10, 2020

This:

# undef __STRICT_ANSI__

causes undefined behaviour. That macro is for the implementation's use, not for yours. Changing it can lead to inconsistent state in libstdc++ headers, e.g. if somebody does this:

#include <type_traits>
#include <fmt/os.h>
#include <random>

If somebody compiles this snippet with -std=c++17 then __STRICT_ANSI__ will be defined when <type_traits> is included, so libstdc++ will define things in "strict" mode (e.g. is_integral_v<__int128> is false) and then the macro gets undefined, and then <random> defines things in "non-strict" mode, so it assumes it can use __int128 as a proper integer type. But it doesn't work, because of the earlier strict definitions in <type_traits>. You get confusing and nonsensical errors from libstdc++ headers.

Do not mess with this macro.

If your code is not compatible with __STRICT_ANSI__ then just tell users they need to use -std=gnu++17 not -std=c++17 so that __STRICT_ANSI__ isn't defined in the first place.

vitaut added a commit that referenced this issue Dec 10, 2020
@vitaut
Copy link
Contributor

vitaut commented Dec 10, 2020

I don't think this workaround is even used anymore. Removed in e737672, thanks for reporting.

@vitaut vitaut closed this as completed Dec 10, 2020
torkeldanielsson pushed a commit to voysys/webrtc-audio-processing that referenced this issue Apr 30, 2024
Undefining this macro makes GCC in standards C++ mode very unhappy:

In file included from D:/msys64/ucrt64/include/c++/13.2.0/bits/requires_hosted.h:31,
                 from D:/msys64/ucrt64/include/c++/13.2.0/string:38,
                 from ..\subprojects\webrtc-audio-processing\webrtc/rtc_base/system/file_wrapper.h:17,
                 from ../subprojects/webrtc-audio-processing/webrtc/rtc_base/system/file_wrapper.cc:11:
D:/msys64/ucrt64/include/c++/13.2.0/x86_64-w64-mingw32/bits/c++config.h:666:2: warning: #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" [-Wcpp]
  666 | #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported"
      |  ^~~~~~~

See: fmtlib/fmt#2059 (comment)

See: #32
@yachoor
Copy link

yachoor commented May 23, 2024

Any chance to get it backported to 4.x branch or is it no longer supported?

fmt 4.1.0 stopped building after updating gcc to 14.1.0 (and my project has to also build with RVCT 4.1 and gcc 4.4.1, so I'm stuck on that branch and 15 years in the past 😭):

In file included from C:/msys64/mingw64/include/c++/14.1.0/cstdlib:41,
                 from C:/msys64/mingw64/include/c++/14.1.0/stdlib.h:36,
                 from C:/gitlab-runner/builds/rau-wEy7/1/<...>/build/win/_deps/fmt-src/fmt/posix.h:22,
                 from C:/gitlab-runner/builds/rau-wEy7/1/<...>/build/win/_deps/fmt-src/fmt/posix.cc:15:
C:/msys64/mingw64/include/c++/14.1.0/x86_64-w64-mingw32/bits/c++config.h:667:2: warning: #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" [-Wcpp]
  667 | #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported"
      |  ^~~~~~~
In file included from C:/gitlab-runner/builds/rau-wEy7/1/apdu/pos/baseApp/build/win/_deps/fmt-src/fmt/format.h:37,
                 from C:/gitlab-runner/builds/rau-wEy7/1/apdu/pos/baseApp/build/win/_deps/fmt-src/fmt/posix.h:30:
C:/msys64/mingw64/include/c++/14.1.0/limits:2100:30: error: exponent has no digits
 2100 |         return __extension__ 0x1.0p-16382Q;
      |                              ^~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits:2114:30: error: exponent has no digits
 2114 |         return __extension__ 0x1.ffffffffffffffffffffffffffffp+16383Q;
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits:2183:30: error: exponent has no digits
 2183 |         return __extension__ 0x1.0p-16494Q;
      |                              ^~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits: In static member function 'static constexpr __float128 std::numeric_limits<__float128>::min()':
C:/msys64/mingw64/include/c++/14.1.0/limits:2100:37: error: unable to find numeric literal operator 'operator""Q'
 2100 |         return __extension__ 0x1.0p-16382Q;
      |                                     ^~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits:2100:37: note: use '-fext-numeric-literals' to enable more built-in suffixes
C:/msys64/mingw64/include/c++/14.1.0/limits:2102:7: error: body of 'constexpr' function 'static constexpr __float128 std::numeric_limits<__float128>::min()' not a return-statement
 2102 |       }
      |       ^
C:/msys64/mingw64/include/c++/14.1.0/limits: In static member function 'static constexpr __float128 std::numeric_limits<__float128>::max()':
C:/msys64/mingw64/include/c++/14.1.0/limits:2114:64: error: unable to find numeric literal operator 'operator""Q'
 2114 |         return __extension__ 0x1.ffffffffffffffffffffffffffffp+16383Q;
      |                                                                ^~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits:2114:64: note: use '-fext-numeric-literals' to enable more built-in suffixes
C:/msys64/mingw64/include/c++/14.1.0/limits:2116:7: error: body of 'constexpr' function 'static constexpr __float128 std::numeric_limits<__float128>::max()' not a return-statement
 2116 |       }
      |       ^
C:/msys64/mingw64/include/c++/14.1.0/limits: In static member function 'static constexpr __float128 std::numeric_limits<__float128>::denorm_min()':
C:/msys64/mingw64/include/c++/14.1.0/limits:2183:37: error: unable to find numeric literal operator 'operator""Q'
 2183 |         return __extension__ 0x1.0p-16494Q;
      |                                     ^~~~~~
C:/msys64/mingw64/include/c++/14.1.0/limits:2183:37: note: use '-fext-numeric-literals' to enable more built-in suffixes
C:/msys64/mingw64/include/c++/14.1.0/limits:2185:7: error: body of 'constexpr' function 'static constexpr __float128 std::numeric_limits<__float128>::denorm_min()' not a return-statement
 2185 |       }
      |       ^

@vitaut
Copy link
Contributor

vitaut commented May 23, 2024

fmt 4.x is not actively maintained but a PR to branch 4.x would be welcome.

yachoor added a commit to yachoor/fmt that referenced this issue May 24, 2024
Backports fix from master branch as the code no longer compiles
on mingw64/gcc 14.1.0 without gnu extensions enabled.
vitaut pushed a commit that referenced this issue May 25, 2024
Backports fix from master branch as the code no longer compiles
on mingw64/gcc 14.1.0 without gnu extensions enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants