[Bug c++/33401] New: Unwanted memset in default constructor

2007-09-11 Thread kbateman at seicorp dot com
This also happens with sparc-sun-solaris2.8 4.1.2
a.cc:
struct buffer {
char buf[65536];
};

buffer *makeBuffer() {
return new buffer();
}
end of a.cc
g++ -O2 -S a.cc
a.s:

movl$65536, (%esp)
call_Znwj
movl%eax, %ebx
movl%ebx, %edx
movl$65536, %eax
movl%eax, 8(%esp)
movl$0, 4(%esp)
movl%edx, (%esp)
callmemset


Give buffer a default constructor and the memset call disappears.
b.cc:
struct buffer {
char buf[65536];
buffer() {}
};
buffer *makeBuffer() {
return new buffer();
}
end of b.cc
g++ -O2 -S b.cc
b.s:
...
movl$65536, (%esp)
call_Znwj
leave
ret
...


-- 
   Summary: Unwanted memset in default constructor
   Product: gcc
   Version: 3.4.6
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kbateman at seicorp dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33401



[Bug c++/33401] Unwanted memset in default constructor

2007-09-11 Thread kbateman at seicorp dot com


--- Comment #1 from kbateman at seicorp dot com  2007-09-11 22:32 ---
Sorry, that a.s is from a run without -O2.  The memset call is still in the -O2
output, though.
a.s:
...
movl$65536, (%esp)
call_Znwj
movl%eax, %ebx
movl$65536, %edx
xorl%eax, %eax
movl%ebx, (%esp)
movl%edx, 8(%esp)
movl%eax, 4(%esp)
callmemset
...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33401



[Bug c++/33401] Unwanted memset in default constructor

2007-09-12 Thread kbateman at seicorp dot com


--- Comment #5 from kbateman at seicorp dot com  2007-09-12 12:52 ---
Whaddaya know.  Section 5-16, Expressions:

If the new-initializer is of the form (), default-initialization shall be
performed (8.5);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33401