This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68280] New: dependent arrays of excessive size not diagnosed
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Nov 2015 22:24:07 +0000
- Subject: [Bug c++/68280] New: dependent arrays of excessive size not diagnosed
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68280
Bug ID: 68280
Summary: dependent arrays of excessive size not diagnosed
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Similar to bug 68266, except in type-dependent expressions, arrays of excessive
size are accepted, leading to overflow/wrapping in sizeof expressions involving
such types. Since bug 68266 is about pointers and affects both C and C++ while
this one is C++ specific and will likely require changes in different places, I
raise this as a separate issue.
$ cat u.cpp && g++ -Wall -Wextra u.cpp && ./a.out
#include <assert.h>
typedef __typeof__ (sizeof 0) size_t;
template <class T, size_t N>
void foo () {
const size_t array_size = sizeof (T[N]);
assert (array_size / sizeof (T) == N);
}
int main ()
{
foo<int, __SIZE_MAX__>();
}
a.out: u.cpp:8: void foo() [with T = int; long unsigned int N =
18446744073709551615ul]: Assertion `array_size / sizeof (T) == N' failed.
Aborted (core dumped)