https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66924

            Bug ID: 66924
           Summary: Bad diagnostic for parameter name used as non-type
                    template argument
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.godfrey99 at gmail dot com
  Target Milestone: ---

GCC does not give a good diagnostic for the following code:

template<int>
constexpr int variable{};

int main() {
    auto f = [] (int x) -> decltype(variable<x>) {return{};};
}

The error is

error: parse error in template argument list
     auto f = [] (int x) -> decltype(variable<x>) {return{};};
                                     ^
main.cpp:5:37: error: template argument 1 is invalid

This code is ill-formed, but the error should explain how x is not a constant
expression (as parameter names are never constant expressions).

Reply via email to