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
* [Bug c++/52964] No warning on negative array size in template instantatiation
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 ` pinskia at gcc dot gnu.org
2012-04-12 23:17 ` manu at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-04-12 23:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-04-12 23:04:05 UTC ---
pinskia@server:~$ ~/treecombine-gcc/bin/gcc t.cc
t.cc: In instantiation of ‘struct S1<4>’:
t.cc:4:49: required from ‘struct S2<int>’
t.cc:5:45: required from ‘void foo(T) [with T = int]’
t.cc:6:21: required from here
t.cc:3:43: error: size of array is negative
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
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
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-12 23:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-12 23:16:35 UTC ---
And with trunk we print:
pr52964.cc: In instantiation of ‘struct S1<4>’:
pr52964.cc:2:49: required from ‘struct S2<int>’
pr52964.cc:3:45: required from ‘void foo(T) [with T = int]’
pr52964.cc:4:21: required from here
pr52964.cc:1:43: error: size of array is negative
template <int N> struct S1 { int arr[N - 5]; };
^
We could easily print the caret for each line. And the locations could be much
better.
I also like more the order of Clang and the extra info about what each thing
is, but we would have to convince Gabriel and/or Jason.
David, what else do you see that could be improved?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: xinliangli at gmail dot com @ 2012-04-12 23:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
--- Comment #3 from davidxl <xinliangli at gmail dot com> 2012-04-12 23:19:33 UTC ---
(In reply to comment #2)
> And with trunk we print:
>
> pr52964.cc: In instantiation of ‘struct S1<4>’:
> pr52964.cc:2:49: required from ‘struct S2<int>’
> pr52964.cc:3:45: required from ‘void foo(T) [with T = int]’
> pr52964.cc:4:21: required from here
> pr52964.cc:1:43: error: size of array is negative
> template <int N> struct S1 { int arr[N - 5]; };
> ^
>
> We could easily print the caret for each line. And the locations could be much
> better.
>
> I also like more the order of Clang and the extra info about what each thing
> is, but we would have to convince Gabriel and/or Jason.
>
> David, what else do you see that could be improved?
With -fsyntax-only, the warning is not emitted -- any reason for that?
David
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
2012-04-12 22:15 [Bug c++/52964] New: No warning on negative array size in template instantatiation xinliangli at gmail dot com
` (2 preceding siblings ...)
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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-04-12 23:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-04-12 23:23:31 UTC ---
(In reply to comment #3)
> With -fsyntax-only, the warning is not emitted -- any reason for that?
Yes because -fsyntax-only does not do template instantatiations at all IIRC.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
2012-04-12 22:15 [Bug c++/52964] New: No warning on negative array size in template instantatiation xinliangli at gmail dot com
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-12 23:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-12 23:25:36 UTC ---
(In reply to comment #4)
> (In reply to comment #3)
> > With -fsyntax-only, the warning is not emitted -- any reason for that?
>
> Yes because -fsyntax-only does not do template instantatiations at all IIRC.
And is there a reason for that?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
2012-04-12 22:15 [Bug c++/52964] New: No warning on negative array size in template instantatiation xinliangli at gmail dot com
` (4 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-13 9:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-13 09:50:01 UTC ---
It's at least somewhat making -fsyntax-only less useful for C++ ... I'd use
-fsyntax-only to have all errors reported and thus all invalid CUs rejected ...
We do report non-syntax errors with -fsyntax-only after all.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/52964] No warning on negative array size in template instantatiation
2012-04-12 22:15 [Bug c++/52964] New: No warning on negative array size in template instantatiation xinliangli at gmail dot com
` (5 preceding siblings ...)
2012-04-13 9:50 ` rguenth at gcc dot gnu.org
@ 2012-10-16 23:09 ` paolo.carlini at oracle dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-16 23:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52964
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-16 23:08:42 UTC ---
Same issue, let's keep only one.
*** This bug has been marked as a duplicate of bug 54706 ***
^ 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).