public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address
@ 2011-10-03 23:41 dberger at oubliette dot org
2011-10-03 23:42 ` [Bug c++/50608] " dberger at oubliette dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: dberger at oubliette dot org @ 2011-10-03 23:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Bug #: 50608
Summary: cannot apply 'offsetof' to a non constant address
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dberger@oubliette.org
$ cat repro.ii
struct A {
int offset;
};
struct B: public A {
};
struct C {
A a;
B b;
};
/* error: cannot apply 'offsetof' to a non constant address */
int fails = __builtin_offsetof (C, b.offset);
int works = (int)(&(((C*)0)->b.offset));
$
looks like a dup of Bug 13648, which claims to be fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
@ 2011-10-03 23:42 ` dberger at oubliette dot org
2011-10-04 9:34 ` [Bug c++/50608] [4.6/4.7 Regression] " paolo.carlini at oracle dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dberger at oubliette dot org @ 2011-10-03 23:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Dan Berger <dberger at oubliette dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |http://gcc.gnu.org/bugzilla
| |/show_bug.cgi?id=13648
--- Comment #1 from Dan Berger <dberger at oubliette dot org> 2011-10-03 23:42:32 UTC ---
Oh, I should say, this code compiles with 4.5.3.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 Regression] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
2011-10-03 23:42 ` [Bug c++/50608] " dberger at oubliette dot org
@ 2011-10-04 9:34 ` paolo.carlini at oracle dot com
2011-10-10 11:29 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-04 9:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-10-04
Summary|cannot apply 'offsetof' to |[4.6/4.7 Regression] cannot
|a non constant address |apply 'offsetof' to a non
| |constant address
Ever Confirmed|0 |1
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-04 09:34:37 UTC ---
Seems a Regression.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 Regression] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
2011-10-03 23:42 ` [Bug c++/50608] " dberger at oubliette dot org
2011-10-04 9:34 ` [Bug c++/50608] [4.6/4.7 Regression] " paolo.carlini at oracle dot com
@ 2011-10-10 11:29 ` rguenth at gcc dot gnu.org
2011-10-10 15:23 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 11:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.6.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 Regression] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (2 preceding siblings ...)
2011-10-10 11:29 ` rguenth at gcc dot gnu.org
@ 2011-10-10 15:23 ` rguenth at gcc dot gnu.org
2011-10-11 9:09 ` mikpe at it dot uu.se
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 15:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Priority|P3 |P2
Known to work| |4.5.3
Known to fail| |4.6.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 Regression] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (3 preceding siblings ...)
2011-10-10 15:23 ` rguenth at gcc dot gnu.org
@ 2011-10-11 9:09 ` mikpe at it dot uu.se
2011-10-11 9:49 ` ebotcazou at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mikpe at it dot uu.se @ 2011-10-11 9:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Mikael Pettersson <mikpe at it dot uu.se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot
| |gnu.org, mikpe at it dot
| |uu.se
--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2011-10-11 09:07:53 UTC ---
This regression started with r159800, Eric Botcazou's PR44100 fix:
http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00854.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 Regression] cannot apply 'offsetof' to a non constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (4 preceding siblings ...)
2011-10-11 9:09 ` mikpe at it dot uu.se
@ 2011-10-11 9:49 ` ebotcazou at gcc dot gnu.org
2011-10-26 17:16 ` [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address jakub at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-10-11 9:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |ebotcazou at gcc dot
|gnu.org |gnu.org
--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-10-11 09:48:05 UTC ---
It turns out that __builtin_offsetof goes through the new code. Fixing...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (5 preceding siblings ...)
2011-10-11 9:49 ` ebotcazou at gcc dot gnu.org
@ 2011-10-26 17:16 ` jakub at gcc dot gnu.org
2011-11-04 21:46 ` ebotcazou at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-10-26 17:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.2 |4.6.3
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-10-26 17:13:25 UTC ---
GCC 4.6.2 is being released.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (6 preceding siblings ...)
2011-10-26 17:16 ` [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address jakub at gcc dot gnu.org
@ 2011-11-04 21:46 ` ebotcazou at gcc dot gnu.org
2011-11-04 21:50 ` ebotcazou at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-04 21:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-04 21:46:10 UTC ---
Author: ebotcazou
Date: Fri Nov 4 21:46:07 2011
New Revision: 180986
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180986
Log:
2011-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR c++/50608
* c-parser.c (c_parser_postfix_expression) <RID_OFFSETOF>: Adjust call
to fold_offsetof.
* c-typeck.c (build_unary_op) <ADDR_EXPR>: Call fold_offsetof_1.
c-family/
* c-common.c (c_fully_fold_internal) <ADDR_EXPR>: Call fold_offsetof_1.
(fold_offsetof_1): Make global. Remove STOP_REF argument and adjust.
<INDIRECT_REF>: Return the argument.
<ARRAY_REF>: Remove special code for negative offset.
Call fold_build_pointer_plus instead of size_binop.
(fold_offsetof): Remove STOP_REF argument and adjust.
* c-common.h (fold_offsetof_1): Declare.
(fold_offsetof): Remove STOP_REF argument.
cp/
* semantics.c (finish_offsetof): Adjust call to fold_offsetof.
* typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1.
Added:
trunk/gcc/testsuite/g++.dg/other/offsetof7.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/c-parser.c
trunk/gcc/c-typeck.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/semantics.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (7 preceding siblings ...)
2011-11-04 21:46 ` ebotcazou at gcc dot gnu.org
@ 2011-11-04 21:50 ` ebotcazou at gcc dot gnu.org
2011-11-04 21:53 ` ebotcazou at gcc dot gnu.org
2012-06-12 3:11 ` amker at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-04 21:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-04 21:49:52 UTC ---
Author: ebotcazou
Date: Fri Nov 4 21:49:49 2011
New Revision: 180988
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180988
Log:
2011-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR c++/50608
* c-parser.c (c_parser_postfix_expression) <RID_OFFSETOF>: Adjust call
to fold_offsetof.
* c-typeck.c (build_unary_op) <ADDR_EXPR>: Call fold_offsetof_1.
c-family/
* c-common.c (c_fully_fold_internal) <ADDR_EXPR>: Call fold_offsetof_1.
(fold_offsetof_1): Make global. Remove STOP_REF argument and adjust.
<INDIRECT_REF>: Return the argument.
<ARRAY_REF>: Remove special code for negative offset.
Call fold_build_pointer_plus instead of size_binop.
(fold_offsetof): Remove STOP_REF argument and adjust.
* c-common.h (fold_offsetof_1): Declare.
(fold_offsetof): Remove STOP_REF argument.
cp/
* semantics.c (finish_offsetof): Adjust call to fold_offsetof.
* typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1.
Added:
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/other/offsetof7.C
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/c-family/ChangeLog
branches/gcc-4_6-branch/gcc/c-family/c-common.c
branches/gcc-4_6-branch/gcc/c-family/c-common.h
branches/gcc-4_6-branch/gcc/c-parser.c
branches/gcc-4_6-branch/gcc/c-typeck.c
branches/gcc-4_6-branch/gcc/cp/ChangeLog
branches/gcc-4_6-branch/gcc/cp/semantics.c
branches/gcc-4_6-branch/gcc/cp/typeck.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (8 preceding siblings ...)
2011-11-04 21:50 ` ebotcazou at gcc dot gnu.org
@ 2011-11-04 21:53 ` ebotcazou at gcc dot gnu.org
2012-06-12 3:11 ` amker at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-04 21:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Version|4.6.1 |4.6.3
Resolution| |FIXED
--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-04 21:52:41 UTC ---
Patch applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
` (9 preceding siblings ...)
2011-11-04 21:53 ` ebotcazou at gcc dot gnu.org
@ 2012-06-12 3:11 ` amker at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: amker at gcc dot gnu.org @ 2012-06-12 3:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50608
--- Comment #9 from amker at gcc dot gnu.org 2012-06-12 03:11:03 UTC ---
Author: amker
Date: Tue Jun 12 03:10:55 2012
New Revision: 188418
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188418
Log:
Backport r180986 from mainline
2011-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR c++/50608
* c-common.c (c_fully_fold_internal) <ADDR_EXPR>: Call fold_offsetof_1.
(fold_offsetof_1): Make global. Remove STOP_REF argument and adjust.
<INDIRECT_REF>: Return the argument.
<ARRAY_REF>: Remove special code for negative offset.
Call fold_build_pointer_plus instead of size_binop.
(fold_offsetof): Remove STOP_REF argument and adjust.
* c-common.h (fold_offsetof_1): Declare.
(fold_offsetof): Remove STOP_REF argument.
PR c++/50608
* c-parser.c (c_parser_postfix_expression) <RID_OFFSETOF>: Adjust call
to fold_offsetof.
* c-typeck.c (build_unary_op) <ADDR_EXPR>: Call fold_offsetof_1.
* g++.dg/other/offsetof7.C: New test.
PR c++/50608
* semantics.c (finish_offsetof): Adjust call to fold_offsetof.
* typeck.c (cp_build_addr_expr_1): Call fold_offsetof_1.
Added:
branches/ARM/embedded-4_6-branch/gcc/c-family/ChangeLog.arm
branches/ARM/embedded-4_6-branch/gcc/cp/ChangeLog.arm
branches/ARM/embedded-4_6-branch/gcc/testsuite/g++.dg/other/offsetof7.C
Modified:
branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm
branches/ARM/embedded-4_6-branch/gcc/c-family/c-common.c
branches/ARM/embedded-4_6-branch/gcc/c-family/c-common.h
branches/ARM/embedded-4_6-branch/gcc/c-parser.c
branches/ARM/embedded-4_6-branch/gcc/c-typeck.c
branches/ARM/embedded-4_6-branch/gcc/cp/semantics.c
branches/ARM/embedded-4_6-branch/gcc/cp/typeck.c
branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-06-12 3:11 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-03 23:41 [Bug c++/50608] New: cannot apply 'offsetof' to a non constant address dberger at oubliette dot org
2011-10-03 23:42 ` [Bug c++/50608] " dberger at oubliette dot org
2011-10-04 9:34 ` [Bug c++/50608] [4.6/4.7 Regression] " paolo.carlini at oracle dot com
2011-10-10 11:29 ` rguenth at gcc dot gnu.org
2011-10-10 15:23 ` rguenth at gcc dot gnu.org
2011-10-11 9:09 ` mikpe at it dot uu.se
2011-10-11 9:49 ` ebotcazou at gcc dot gnu.org
2011-10-26 17:16 ` [Bug c++/50608] [4.6/4.7 regression] cannot apply 'offsetof' to a non-constant address jakub at gcc dot gnu.org
2011-11-04 21:46 ` ebotcazou at gcc dot gnu.org
2011-11-04 21:50 ` ebotcazou at gcc dot gnu.org
2011-11-04 21:53 ` ebotcazou at gcc dot gnu.org
2012-06-12 3:11 ` amker 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).