public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/23480] New: default-initializing variable size array new expression does not work @ 2005-08-19 13:05 avi at argo dot co dot il 2005-08-19 13:12 ` [Bug c++/23480] " pinskia at gcc dot gnu dot org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: avi at argo dot co dot il @ 2005-08-19 13:05 UTC (permalink / raw) To: gcc-bugs the following function int* f(int n) { return new int[n](); } translates to _Z1fi: .LFB2: pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: sall $2, 8(%ebp) leave .LCFI2: jmp _Znaj which does not default-initialize the array. -- Summary: default-initializing variable size array new expression does not work Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: avi at argo dot co dot il CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-redhat-linux GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23480 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/23480] default-initializing variable size array new expression does not work 2005-08-19 13:05 [Bug c++/23480] New: default-initializing variable size array new expression does not work avi at argo dot co dot il @ 2005-08-19 13:12 ` pinskia at gcc dot gnu dot org 2005-08-19 13:23 ` [Bug c++/23480] default-initializing variable size array new expression for basic types " pinskia at gcc dot gnu dot org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-08-19 13:12 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-19 13:04 ------- new int[2] () is broken in 3.4.x, see PR 20427. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23480 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/23480] default-initializing variable size array new expression for basic types does not work 2005-08-19 13:05 [Bug c++/23480] New: default-initializing variable size array new expression does not work avi at argo dot co dot il 2005-08-19 13:12 ` [Bug c++/23480] " pinskia at gcc dot gnu dot org @ 2005-08-19 13:23 ` pinskia at gcc dot gnu dot org 2005-08-20 2:37 ` pinskia at gcc dot gnu dot org 2005-08-20 2:43 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-08-19 13:23 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Summary|default-initializing |default-initializing |variable size array new |variable size array new |expression does not work |expression for basic types | |does not work http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23480 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/23480] default-initializing variable size array new expression for basic types does not work 2005-08-19 13:05 [Bug c++/23480] New: default-initializing variable size array new expression does not work avi at argo dot co dot il 2005-08-19 13:12 ` [Bug c++/23480] " pinskia at gcc dot gnu dot org 2005-08-19 13:23 ` [Bug c++/23480] default-initializing variable size array new expression for basic types " pinskia at gcc dot gnu dot org @ 2005-08-20 2:37 ` pinskia at gcc dot gnu dot org 2005-08-20 2:43 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-08-20 2:37 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-20 02:30 ------- Testcase which was attached on PR 20427: #include <iostream> void f(int n) { int * a = new int [n] () ; for (int i = 0; i < n; ++i) { std::cout << a[i]++ << ' '; } std::cout << '\n'; delete[] a; } int main() { f(5); f(5); f(5); f(5); } Which shows the issue more clearer. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23480 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/23480] default-initializing variable size array new expression for basic types does not work 2005-08-19 13:05 [Bug c++/23480] New: default-initializing variable size array new expression does not work avi at argo dot co dot il ` (2 preceding siblings ...) 2005-08-20 2:37 ` pinskia at gcc dot gnu dot org @ 2005-08-20 2:43 ` pinskia at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-08-20 2:43 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-20 02:37 ------- 3.2.3 and 3.0.4 rejected the code: t.cc: In function `void f(int)': t.cc:4: variable-sized object of type `int[n]' may not be initialized No recent (from 2.95.3 and above) GCC version got this right (well at least the versions I tested). Here is a self contained testcase which fails and should not: extern "C" void abort (); void f(int n) { int * a = new int [n] () ; for (int i = 0; i < n; ++i) { if (a[i]) abort (); a[i]++; } delete[] a; } int main() { f(5); f(5); f(5); f(5); } Even ICC 8.1 gets this wrong :). -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |wrong-code Known to fail| |3.3.3 3.4.0 4.0.0 4.1.0 | |2.95.3 Last reconfirmed|0000-00-00 00:00:00 |2005-08-20 02:37:17 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23480 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-08-20 2:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-08-19 13:05 [Bug c++/23480] New: default-initializing variable size array new expression does not work avi at argo dot co dot il 2005-08-19 13:12 ` [Bug c++/23480] " pinskia at gcc dot gnu dot org 2005-08-19 13:23 ` [Bug c++/23480] default-initializing variable size array new expression for basic types " pinskia at gcc dot gnu dot org 2005-08-20 2:37 ` pinskia at gcc dot gnu dot org 2005-08-20 2:43 ` pinskia at gcc dot gnu dot org
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).