This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52964] New: No warning on negative array size in template instantatiation
- From: "xinliangli at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 12 Apr 2012 22:15:05 +0000
- Subject: [Bug c++/52964] New: No warning on negative array size in template instantatiation
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
Bug #: 52964
Summary: No warning on negative array size in template
instantatiation
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: xinliangli@gmail.com
template <int N> struct S1 { int arr[N - 5]; };
template <typename T> struct S2 { S1<sizeof(T)> s1; };
template <typename T> void foo(T x) { S2<T> s2; }
void test() { foo(42); }
/* From Clang:
templates1.cpp:1:38: error: 'arr' declared as an array with a negative
size
template <int N> struct S1 { int arr[N - 5]; };
^~~~~
templates1.cpp:2:49: note: in instantiation of template class 'S1<4>'
requested here
template <typename T> struct S2 { S1<sizeof(T)> s1; };
^
templates1.cpp:3:45: note: in instantiation of template class 'S2<int>'
requested here
template <typename T> void foo(T x) { S2<T> s2; }
^
templates1.cpp:4:15: note: in instantiation of function template
specialization 'foo<int>' requested here
void test() { foo(42); }
============================================== */