C++ no longer defines __FRACT_FBIT__
GCC's C++ front end no longer predefines the __FRACT_FBIT__ macro, fixing a bug where it was incorrectly available in C++ code.
The GCC C++ front end previously defined the FRACT_FBIT macro, which is specific to the C standard. This change removes the definition of this macro in C++ contexts, aligning GCC’s behavior with the C++ standard and preventing potential issues when using the macro in C++ code. A new test case verifies this corrected behavior.
In Details
The c_cpp_builtins function in c-cppbuiltin.cc is responsible for defining language-specific preprocessor macros. The fix involves conditionally disabling the __FRACT_FBIT__ definition when compiling C++ code, which previously was incorrectly enabled for both C and C++. This macro is typically associated with fixed-point arithmetic in C, and its presence in C++ could lead to unexpected behavior or compilation errors for C++ developers not expecting its availability.
For Context
Compilers like GCC have built-in definitions called 'macros' that typically provide information about the compilation environment or language features. This change addresses a bug in GCC where a specific macro, __FRACT_FBIT__, which is meant for the C programming language (especially for a niche feature called fixed-point arithmetic), was also being defined when compiling C++ code. This could lead to unexpected behavior for C++ developers who wouldn't expect this C-specific macro to be available. By removing its definition in C++, the compiler now adheres more strictly to the C++ standard, ensuring that C++ programs rely only on C++-specific features and macros.