[Bug c++/69638] array out of bounds access accepted in constexpr function invocation
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Aug 28 08:17:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69638
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
I get the following errors with gcc8:
$ /usr/local/bin/g++ -c -S -Wall -Wextra -Wpedantic -std=c++14 -xc++ 69638.cc
69638.cc:11:28: in constexpr expansion of ‘foo()’
69638.cc:11:33: error: array subscript value ‘99’ is outside the bounds of
array ‘a’ of type ‘A [3]’
struct B { unsigned b: foo () + 1; };
^
69638.cc:7:4: note: declared here
A a [3] = { 1, 2, 3 };
^
69638.cc:11:33: error: bit-field ‘B::b’ width not an integer constant
struct B { unsigned b: foo () + 1; };
^
69638.cc: In function ‘constexpr int bar(int)’:
69638.cc:16:8: warning: ISO C++ forbids variable length array ‘a’ [-Wvla]
A a [n] = { 1, 2, 3 };
^
69638.cc: At global scope:
69638.cc:21:21: in constexpr expansion of ‘bar(1)’
69638.cc:21:27: error: array subscript value ‘1’ is outside the bounds of array
‘a’ of type ‘A [n]’
unsigned c: bar (1) + 1;
^
69638.cc:16:4: note: declared here
A a [n] = { 1, 2, 3 };
^
69638.cc:21:27: error: bit-field ‘C::c’ width not an integer constant
unsigned c: bar (1) + 1;
^
$
Were these the errors you were expecting? Leaving UNCONFIRMED because I'm not
sure...
More information about the Gcc-bugs
mailing list