Menu ▾ ▴

syntaxError on a pack expansion of decltype in a qualified template default argument followed by `>>`

2026-11-10
2026-11-10
  • Andreas Burnickl

    Version: Cppcheck 2.19.0 and 2.22.0 (built from the 2.22.0 tag), Ubuntu 26.04.

    Code (GCC and Clang compile it with -std=c++11, including an instantiation f<int>()):

    namespace n { template <typename... Ts> struct S {}; }
    template <typename... Ts, typename = n::S<decltype(Ts())...>>
    void f() {}
    
    $ cppcheck --language=c++ --std=c++11 h.cpp
    h.cpp:2:60: error: syntax error [syntaxError]
    template <typename... Ts, typename = n::S<decltype(Ts())...>>
                                                               ^
    

    No error when any one of these changes:

    • > > instead of >> at the end;
    • S<...> unqualified instead of n::S<...>;
    • n::S<Ts...> without decltype;
    • the same type in a function body (n::S<decltype(Ts())...> s;) or in an alias template
      (using A = n::S<decltype(Ts())...>;).

    Impact: the syntax error ends the analysis of every translation unit that includes the header,
    so the project has to switch cppcheck off. It is the std::void_t idiom for SFINAE,
    typename = internal::Void<decltype(T{internal::DeclVal<Ts>()})...>>, in C++11 code.

     
  • CHR

    CHR - 2026-11-10

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15192

     

Log in to post a comment.