Skip to content

Can't #include <llvm/ADT/FloatingPointMode.h> with -std=c++23 with clang++ 21.1.0-rc1 #149610

@chriselrod

Description

@chriselrod
#include <llvm/ADT/FloatingPointMode.h>

int main(){
  return 0;
}

I get

❯ clang++ llvminclude.cpp

~/Documents/progwork/cxx/test
❯ clang++ -std=c++23 llvminclude.cpp
In file included from llvminclude.cpp:1:
In file included from /usr/include/llvm/ADT/FloatingPointMode.h:19:
In file included from /usr/include/llvm/ADT/StringSwitch.h:16:
/usr/include/llvm/ADT/StringRef.h:864:22: error: 'enable_if' attribute expression never
      produces a constant expression
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                      ^
/usr/include/llvm/ADT/FloatingPointMode.h:193:14: note: in instantiation of function
      template specialization 'llvm::StringLiteral::StringLiteral<1UL>' requested here
  193 |       .Cases("", "ieee", DenormalMode::IEEE)
      |              ^
/usr/include/llvm/ADT/StringRef.h:864:49: note: read of variable 'Str' whose value is not
      known
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                                                 ^
/usr/include/llvm/ADT/StringRef.h:860:42: note: declared here
  860 |     constexpr StringLiteral(const char (&Str)[N])
      |                                          ^
/usr/include/llvm/ADT/StringRef.h:864:22: error: 'enable_if' attribute expression never
      produces a constant expression
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                      ^
/usr/include/llvm/ADT/FloatingPointMode.h:193:18: note: in instantiation of function
      template specialization 'llvm::StringLiteral::StringLiteral<5UL>' requested here
  193 |       .Cases("", "ieee", DenormalMode::IEEE)
      |                  ^
/usr/include/llvm/ADT/StringRef.h:864:49: note: read of variable 'Str' whose value is not
      known
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                                                 ^
/usr/include/llvm/ADT/StringRef.h:860:42: note: declared here
  860 |     constexpr= StringLiteral(const char (&Str)[N])
      |                                          ^
/usr/include/llvm/ADT/StringRef.h:864:22: error: 'enable_if' attribute expression never
      produces a constant expression
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                      ^
/usr/include/llvm/ADT/FloatingPointMode.h:194:13: note: in instantiation of function
      template specialization 'llvm::StringLiteral::StringLiteral<14UL>' requested here
  194 |       .Case("preserve-sign", DenormalMode::PreserveSign)
      |             ^
/usr/include/llvm/ADT/StringRef.h:864:49: note: read of variable 'Str' whose value is not
      known
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                                                 ^
/usr/include/llvm/ADT/StringRef.h:860:42: note: declared here
  860 |     constexpr StringLiteral(const char (&Str)[N])
      |                                          ^
/usr/include/llvm/ADT/StringRef.h:864:22: error: 'enable_if' attribute expression never
      produces a constant expression
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                      ^
/usr/include/llvm/ADT/FloatingPointMode.h:196:13: note: in instantiation of function
      template specialization 'llvm::StringLiteral::StringLiteral<8UL>' requested here
  196 |       .Case("dynamic", DenormalMode::Dynamic)
      |             ^
/usr/include/llvm/ADT/StringRef.h:864:49: note: read of variable 'Str' whose value is not
      known
  864 |         __attribute((enable_if(__builtin_strlen(Str) == N - 1,
      |                                                 ^
/usr/include/llvm/ADT/StringRef.h:860:42: note: declared here
  860 |     constexpr StringLiteral(const char (&Str)[N])
      |                                          ^
4 errors generated.

This works with clang++ 20, as well as with

clang version 21.0.0git ([email protected]:llvm/llvm-project d4331344ac45979f5bc58508d7e186f86fe907bd)

This is

commit d4331344ac45979f5bc58508d7e186f86fe907bd
Author: Nilanjana Basu <[email protected]>
Date:   Wed Jul 2 14:41:30 2025 -0700

    [Clang][Driver][SamplePGO] Introduce -fno_sample_profile_use_profi flag for SamplePGO (#145957)
    
    This flag allows opting out of using profile inference pass for SamplePGO.

so the regression was some time in the past couple of weeks.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions