[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

--- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org ---
That's not how static_assert works.


[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org ---
(In reply to Udo Steinberg from comment #0)
 In the attached test case, for each compile-time constant value x,

x is not a compile-time constant, it's a run-time parameter of the function.


 only one
 static_assert in the switch statement should be checked.

Why? All four are in the body of the function template and all four are
compiled for every instantiation, so all four are checked on every
instantiation

A 'switch' is a run-time condition.

 Looks like all four
 of them are checked every time.

That's exactly what's supposed to happen.


[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread us15 at os dot inf.tu-dresden.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

--- Comment #3 from Udo Steinberg us15 at os dot inf.tu-dresden.de ---
Created attachment 33035
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33035action=edit
Testcase 2

Then, similar to this new test case, I would expect something like the
following:

g++ -std=gnu++11 foo.cc -o foo

foo.cc: In function 'void check_type(unsigned int, unsigned int)':
foo.cc:10:17: error: non-constant condition for static assertion
 case 0: static_assert (s == sizeof (uint16), must use 16bit type);
break;
 ^
foo.cc:10:17: error: 's' is not a constant expression

If the compiler does not treat 'x' in the first test case as a constant, it
would be good to issue a warning like it does for 's' in the second test case.


[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org ---
(In reply to Udo Steinberg from comment #3)
 Created attachment 33035 [details]
 Testcase 2
 
 Then, similar to this new test case, I would expect something like the
 following:
 
 g++ -std=gnu++11 foo.cc -o foo
 
 foo.cc: In function 'void check_type(unsigned int, unsigned int)':
 foo.cc:10:17: error: non-constant condition for static assertion
  case 0: static_assert (s == sizeof (uint16), must use 16bit
 type); break;
  ^
 foo.cc:10:17: error: 's' is not a constant expression
 
 If the compiler does not treat 'x' in the first test case as a constant, it
 would be good to issue a warning like it does for 's' in the second test
 case.

That is still correct s is not a constant expression.


[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread us15 at os dot inf.tu-dresden.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

--- Comment #5 from Udo Steinberg us15 at os dot inf.tu-dresden.de ---
(In reply to Andrew Pinski from comment #4)

 That is still correct s is not a constant expression.

Yes, I'm saying a similar warning should be emitted for x.


[Bug c++/61660] static_assert triggering when it should not

2014-06-30 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61660

--- Comment #6 from Marc Glisse glisse at gcc dot gnu.org ---
(In reply to Udo Steinberg from comment #5)
 Yes, I'm saying a similar warning should be emitted for x.

No it should not, you are using x and s in completely different ways.