On Mon, Sep 07, 2026 at 11:31:21PM +0800, Jakit Liang wrote:
> I did some additional investigation and can reproduce the parsing
> failure outside CLion, using Debian's standalone clangd 19.1.7 in WSL2.
> 
> The important condition is that clangd is given the GCC bfloat16 feature
> macro, as happens in the CLion configuration. The following minimal
> predefines file is sufficient:
> 
> ```
> #define __BFLT16_MANT_DIG__ 8
> #define __BFLT16_DIG__ 2
> ```

gcc has a few hundreds of predefined macros, each predefined macro
means something, if you incorrectly define any of them, the same or other
programs can misbehave.
There is no point trying to allow incorrectly redefining just one of those
macros.  The predefined macros are usually in implementation namespace (or
even mandated by the standard, see the __cpp* macros) and changing them
makes the program invalid.

> Thus CLion is not required to trigger the parser diagnostic. In CLion,
> the same condition arises because its clangd integration supplies a
> snapshot of the selected GCC 14.2.0 toolchain's predefined macros via
> an `-imacros` file, including `__BFLT16_DIG__=2`.

Then CLion is broken.

        Jakub

Reply via email to