public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/53505] New: bitfield with bool type generated broken object code @ 2012-05-28 8:00 rockeet at gmail dot com 2012-05-28 13:26 ` [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file jakub at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: rockeet at gmail dot com @ 2012-05-28 8:00 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 Bug #: 53505 Summary: bitfield with bool type generated broken object code Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: rockeet@gmail.com compiler flag: -Wall -Wextra -O[0|1|2|3|fast] All optimization levels: 1,2,3,fast reproduce the bug -O0 is OK. The expected output is 0 //================================================ $g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/opt/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.7.0-RC-20120314/configure --prefix=/opt --with-gmp=/opt --with-mpfr=/opt --with-mpc=/opt --with-ppl=/opt --with-cloog=/opt --with-local-prefix=/opt --enable-languages=c,c++ : (reconfigured) ../gcc-4.7.0-RC-20120314/configure --prefix=/opt --with-gmp=/opt --with-mpfr=/opt --with-mpc=/opt --with-ppl=/opt --with-cloog=/opt --with-local-prefix=/opt --enable-languages=c,c++,fortran Thread model: posix gcc version 4.7.0 20120314 (prerelease) (GCC) //================================================ #include <string.h> #include <stdio.h> #include <stdlib.h> #include <vector> #if 1 #define BIT bool // reproduce the bug #else #define BIT unsigned // bug vanished #endif struct A { unsigned int a; unsigned char c1, c2; BIT b1 : 1; BIT b2 : 1; BIT b3 : 1; A() { memset(this, -1, sizeof(A)); a = 0; c1 = c2 = 0; b1 = 0; b2 = 0; b3 = 0; } }; void f(const std::vector<A>& v) { int s = 0; for (int i = 0, n = v.size(); i < n; ++i) { const A a = v[i]; // produce the bug // const A&a = v[i]; // bug vanished if 'a' is a const reference s += a.b1 ? 1 : 0; } printf("%d\n", s); } int main(int argc, char* argv[]) { size_t size = argc < 2 ? 100 : atoi(argv[1]); std::vector<A> v(size); f(v); return 0; } ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com @ 2012-05-28 13:26 ` jakub at gcc dot gnu.org 2012-05-28 13:39 ` jakub at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 13:26 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-05-28 CC| |jakub at gcc dot gnu.org Target Milestone|--- |4.7.1 Summary|bitfield with bool type |[4.7/4.8 Regression] |generated broken object |bitfield with bool type |file |generated broken object | |file Ever Confirmed|0 |1 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 12:53:19 UTC --- Started with http://gcc.gnu.org/viewcvs?view=revision&revision=184214 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com 2012-05-28 13:26 ` [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file jakub at gcc dot gnu.org @ 2012-05-28 13:39 ` jakub at gcc dot gnu.org 2012-05-28 14:00 ` jakub at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 13:39 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 13:25:34 UTC --- SRA creates: <unnamed-unsigned:1> a$6; ... a$6_21 = MEM[(const struct A &)D.9923_20 + 6]; D.10122_23 = (int) a$6_21; which expansion doesn't handle as extract_bit_field (both MEM_REF and TARGET_MEM_REF are expanded that way), so the zero extension is performed just as QI->SImode zero extension. I'd say that SRA shouldn't be creating such MEM_REFs and instead should keep the BIT_FIELD_REFs. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com 2012-05-28 13:26 ` [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file jakub at gcc dot gnu.org 2012-05-28 13:39 ` jakub at gcc dot gnu.org @ 2012-05-28 14:00 ` jakub at gcc dot gnu.org 2012-05-28 14:11 ` jakub at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 14:00 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 13:39:12 UTC --- That revision added: + /* But leave bitfield accesses alone. */ + && (root->offset % BITS_PER_UNIT) == 0) Here root->offset % BITS_PER_UNIT is 0, still it is a bitfield and IMHO we should leave it alone. The question is how to differentiate bitfields at byte boundary offsets from e.g. non-bitfield _Bool where it should be user's responsibility to keep just 0 or 1 in the whole byte. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com ` (2 preceding siblings ...) 2012-05-28 14:00 ` jakub at gcc dot gnu.org @ 2012-05-28 14:11 ` jakub at gcc dot gnu.org 2012-05-28 14:29 ` jakub at gcc dot gnu.org 2012-05-28 14:36 ` jakub at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 14:11 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 14:09:05 UTC --- Ah, sounds like dup of PR53438. *** This bug has been marked as a duplicate of bug 53438 *** ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com ` (3 preceding siblings ...) 2012-05-28 14:11 ` jakub at gcc dot gnu.org @ 2012-05-28 14:29 ` jakub at gcc dot gnu.org 2012-05-28 14:36 ` jakub at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 14:29 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 14:28:06 UTC --- Author: jakub Date: Mon May 28 14:28:00 2012 New Revision: 187931 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187931 Log: PR tree-optimization/53505 * c-c++-common/torture/pr53505.c: New test. Added: trunk/gcc/testsuite/c-c++-common/torture/pr53505.c Modified: trunk/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com ` (4 preceding siblings ...) 2012-05-28 14:29 ` jakub at gcc dot gnu.org @ 2012-05-28 14:36 ` jakub at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2012-05-28 14:36 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53505 --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-28 14:28:55 UTC --- Author: jakub Date: Mon May 28 14:28:42 2012 New Revision: 187932 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187932 Log: PR tree-optimization/53505 * c-c++-common/torture/pr53505.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/c-c++-common/torture/pr53505.c Modified: branches/gcc-4_7-branch/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-05-28 14:29 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-05-28 8:00 [Bug c++/53505] New: bitfield with bool type generated broken object code rockeet at gmail dot com 2012-05-28 13:26 ` [Bug c++/53505] [4.7/4.8 Regression] bitfield with bool type generated broken object file jakub at gcc dot gnu.org 2012-05-28 13:39 ` jakub at gcc dot gnu.org 2012-05-28 14:00 ` jakub at gcc dot gnu.org 2012-05-28 14:11 ` jakub at gcc dot gnu.org 2012-05-28 14:29 ` jakub at gcc dot gnu.org 2012-05-28 14:36 ` jakub at gcc dot gnu.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).