[Bug c++/87413] strlen accepted in array declaration

2018-09-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87413

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-09-24
 Blocks||83819
 Ever confirmed|0   |1

--- Comment #4 from Martin Sebor  ---
Let me confirm this for the missing pedantic warning.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83819
[Bug 83819] [meta-bug] missing strlen optimizations

[Bug c++/87413] strlen accepted in array declaration

2018-09-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87413

Martin Sebor  changed:

   What|Removed |Added

   Keywords||diagnostic
 CC||msebor at gcc dot gnu.org
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=80265

--- Comment #3 from Martin Sebor  ---
As Jonathan already mentioned, treating __builtin_strlen("string") (among other
string function calls) as a constant integer expression is a useful extension
accepted by several C++ compilers, including Clang and ICC 18 (see also
pr80265).

G++ accepts the test case in C++ 11 mode and later, but rejects it with an
error in C++ 98 mode.  Since C++ requires array bounds to be constant
expressions and calls to functions are not such expressions, it might be worth
issuing a pedantic warning on the strlen case in C++ 11 mode and later.

[Bug c++/87413] strlen accepted in array declaration

2018-09-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87413

--- Comment #2 from Jonathan Wakely  ---
It's a GNU extension in C++, so we can decide whether it's valid or not.

[Bug c++/87413] strlen accepted in array declaration

2018-09-24 Thread bernd.edlinger at hotmail dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87413

--- Comment #1 from Bernd Edlinger  ---
so current trunk accepts the variant test1.c with __builtin_strlen
both C and C++:

$ gcc -Wall -S test1.c
$ gcc -x c++ -Wall -S test1.c

Don't know it that is valid.