This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/50445] Rejects use of constant expression using a pointer non-type template parameter


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2017-08-18
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
The error message is now:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic 50445.cc
50445.cc: In instantiation of ‘const int X<(& values)>::val0’:
50445.cc:7:22:   required from here
50445.cc:4:19: error: the value of ‘values’ is not usable in a constant
expression
  static int const val0 = values[0];
                   ^~~~
50445.cc:1:18: note: ‘values’ was not declared ‘constexpr’
 extern int const values[] = { 1, 2, 3 };
                  ^~~~~~
50445.cc:7:26: error: size of array ‘array’ is not an integral
constant-expression
 int array[X<values>::val0];
                          ^
$

...which I think clears things up. Although maybe the note saying 'values' was
not declared 'constexpr' could have a fix-it hint added to it showing where to
insert the 'constexpr'? Putting in WAITING to see what the reporter thinks.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]