public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52964] New: No warning on negative array size in template instantatiation
@ 2012-04-12 22:15 xinliangli at gmail dot com
  2012-04-12 23:04 ` [Bug c++/52964] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: xinliangli at gmail dot com @ 2012-04-12 22:15 UTC (permalink / raw)
  To: gcc-bugs

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); }
==============================================     */


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-10-16 23:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 22:15 [Bug c++/52964] New: No warning on negative array size in template instantatiation xinliangli at gmail dot com
2012-04-12 23:04 ` [Bug c++/52964] " pinskia at gcc dot gnu.org
2012-04-12 23:17 ` manu at gcc dot gnu.org
2012-04-12 23:20 ` xinliangli at gmail dot com
2012-04-12 23:24 ` pinskia at gcc dot gnu.org
2012-04-12 23:25 ` manu at gcc dot gnu.org
2012-04-13  9:50 ` rguenth at gcc dot gnu.org
2012-10-16 23:09 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).