[Bug c++/29106] New: sizeof(*var) in expression drops entire line of code out of compile
#include int main() { int* const savepos = sizeof(*savepos) ? 0 : 0; // code for the next line is left out! printf("size of thingy is %d\n", sizeof(*savepos)); } Any line of code containing sizeof(*savepos) gets stripped. If you compile and run this, nothing is printed. -- Summary: sizeof(*var) in expression drops entire line of code out of compile Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: deb at pixar dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29106
[Bug c++/29106] sizeof(*var) in expression drops entire line of code out of compile
--- Comment #1 from deb at pixar dot com 2006-09-16 14:18 --- /* Using built-in specs. Target: x86_64-redhat-linux-gnu Configured with: ../gcc-4.0.3/configure x86_64-redhat-linux-gnu --prefix=/pixar/d2/sets/t\ ools-03 --exec-prefix=/pixar/d2/sets/tools-03 --bindir=/pixar/d2/sets/tools-03/bin --sbin\ dir=/pixar/d2/sets/tools-03/sbin --sysconfdir=/pixar/d2/sets/tools-03/etc --datadir=/pixa\ r/d2/sets/tools-03/share --includedir=/pixar/d2/sets/tools-03/include --libdir=/pixar/d2/\ sets/tools-03/lib --libexecdir=/pixar/d2/sets/tools-03/libexec --localstatedir=/pixar/d2/\ sets/tools-03/var --sharedstatedir=/pixar/d2/sets/tools-03/com --mandir=/pixar/d2/sets/to\ ols-03/man --infodir=/pixar/d2/sets/tools-03/info --enable-version-specific-runtime-libs \ --enable-languages=c++,objc,f95 --enable-threads=posix --enable-shared --enable-mudflap Thread model: posix gcc version 4.0.3 Compile as: g++ bug.cpp Issue: Calll to printf left out. (Indeed, any line of code that contains sizeof(*savepos) gets tossed on the floor. I assume since sizeof() is a compile-time construct, something took this a bit too far? */ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29106
[Bug c++/29375] New: gcc4.0.3 produces code that copies a structure twice
Using built-in specs. Target: x86_64-redhat-linux-gnu Configured with: ../gcc-4.0.3/configure x86_64-redhat-linux-gnu --with-ld=/pixar/d2/sets/tools-03/bin/ld --with-as=/pixar/d2/sets/tools-03/bin/as --prefix=/pixar/d2/sets/tools-03 --exec-prefix=/pixar/d2/sets/tools-03 --bindir=/pixar/d2/sets/tools-03/bin --sbindir=/pixar/d2/sets/tools-03/sbin --sysconfdir=/pixar/d2/sets/tools-03/etc --datadir=/pixar/d2/sets/tools-03/share --includedir=/pixar/d2/sets/tools-03/include --libdir=/pixar/d2/sets/tools-03/lib --libexecdir=/pixar/d2/sets/tools-03/libexec --localstatedir=/pixar/d2/sets/tools-03/var --sharedstatedir=/pixar/d2/sets/tools-03/com --mandir=/pixar/d2/sets/tools-03/man --infodir=/pixar/d2/sets/tools-03/info --enable-version-specific-runtime-libs --enable-symvers --enable-languages=c++,objc,f95 --enable-threads=posix --enable-shared --enable-mudflap Thread model: posix gcc version 4.0.3 --code struct Big { char data[1024]; }; void ByValue(Big); void MakeACopy() { Big stuff; ByValue(stuff); } --- The relevant assembly code, when compiled as: g++ -O2 -S prog.cpp .globl _Z9MakeACopyv .type _Z9MakeACopyv, @function _Z9MakeACopyv: .LFB2: pushq %rbx .LCFI0: movl$1024, %edx subq$3072, %rsp .LCFI1: leaq2048(%rsp), %rbx leaq1024(%rsp), %rsi movq%rbx, %rdi callmemcpy movq%rbx, %rsi movq%rsp, %rdi movl$1024, %edx callmemcpy call_Z7ByValue3Big addq$3072, %rsp popq%rbx ret --- I'm far from an export, but it sure looks to me like memcpy is being called twice to copy the data! This is supported by the fact that gcc3.3.2 only emits code to copy it once, and that code runs twice as fast. Also, gcc3.3.2 inlines the memcpy, while gcc4.0.3 does not. I assume that's a regression as well? If not, what's the best option to tell gcc4.0.3 to inline the copy? -- Summary: gcc4.0.3 produces code that copies a structure twice Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: deb at pixar dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29375
[Bug c++/29375] gcc4.0.3 produces code that copies a structure twice
--- Comment #2 from deb at pixar dot com 2006-10-07 04:00 --- (In reply to comment #1) > I think this was fixed in 4.0.4 by the patch which fixed PR 23372. > For various reasons, upgrading to 4.0.4 isn't an option at this time. (a) How do I obtain the specific patch you are referring to and (b) any idea if it would be safe to apply this patch to our current 4.0.3 source? Also, are you saying that the fix for PR23372 also brings us back to avoiding direct calls to memcpy? That may be the bigger issue; the number of POD datastructures we're copying around is probably very small. I was really trying to uncover why we were calling mempcy directly when I noticed the second copy. Thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29375
[Bug c++/29375] gcc4.0.3 produces code that copies a structure twice
--- Comment #3 from deb at pixar dot com 2006-10-07 04:01 --- Oops, I see how to get the patch. Never mind that part of the question, thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29375