Skip to content

Clang-23 compilation error with -std=26 #768

Open

Description

@anders-wind

There's a bug in clang when compiling with -std=26, and reflectcpp is hit by that.

e.hpp:23:10: error: no matching constructor for initialization of 'internal::StringLiteral<5>'
   23 |   return internal::StringLiteral<5>('f',
      |          ^                          ~~~~
   24 |                                     static_cast<char>('0' + ((_i / 100) % 10)),
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   25 |                                     static_cast<char>('0' + ((_i / 10) % 10)),
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   26 |                                     static_cast<char>('0' + (_i % 10)));
...
include/rfl/json/../parsing/../internal/StringLiteral.hpp:21:13: note: candidate constructor not viable: requires single argument '_arr', but 4 arguments were provided
   21 |   constexpr StringLiteral(const std::array<char, N> _arr) : arr_(_arr) {}
...
/home/anderswind/projects/eex-logger/build/vcpkg_installed/high-performance-x64-linux/include/rfl/json/../parsing/../internal/StringLiteral.hpp:17:13: note: candidate template ignored: constraints not satisfied [with _chars:auto = <char, char, char, char>]
   17 |   constexpr StringLiteral(const auto... _chars)

Apparently the concept of the variadic char constructor is not being hit because the char's are char not const char

Link to clang bug report: llvm/llvm-project#238720

One way to work around it is the following git diff

diff --git a/include/rfl/internal/StringLiteral.hpp b/include/rfl/internal/StringLiteral.hpp
--- a/include/rfl/internal/StringLiteral.hpp
+++ b/include/rfl/internal/StringLiteral.hpp
@@ -14,8 +14,9 @@
 /// for the parameters names in the NamedTuples.
 template <size_t N>
 struct StringLiteral {
-  constexpr StringLiteral(const auto... _chars)
-    requires (std::is_same_v<decltype(_chars), const char> && ...)
+  template <class... Cs>
+  constexpr StringLiteral(const Cs... _chars)
+    requires (std::is_same_v<Cs, char> && ...)
     : arr_{_chars..., '\0'} {}
 
   constexpr StringLiteral(const std::array<char, N> _arr) : arr_(_arr) {}

Activity

  1. changed the title [-]Clang-23 compilation[/-] [+]Clang-23 compilation error with -std=26[/+] on Nov 4, 2026
  2. liuzicheng1987 commented on Nov 5, 2026

    @liuzicheng1987
    Collaborator

    @anders-wind OK. Since you seem to have a fix, could you open a PR?

  3. anders-wind commented on Nov 5, 2026

    @anders-wind
    Author

    Looks like it might have been fixed in the meantime since the latest release. Ill check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions