public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro
@ 2003-06-03 1:34 bangerth@dealii.org
2003-06-03 2:29 ` [Bug c++/11072] " rwgk@yahoo.com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: bangerth@dealii.org @ 2003-06-03 1:34 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
Summary: [3.4 regression] Implementation of offsetof macro
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bangerth@dealii.org
CC: gcc-bugs@gcc.gnu.org
OtherBugsDependingO 10922
nThis:
[Yet another problem with 10922. It is similar to 9881, which is why I CC:
you, Nathan.]
This fails on mainline:
-----------------------------
#include <cstddef>
template <typename> struct S {
int i, j;
static const unsigned int value = offsetof(S,j);
};
-----------------------------
g/x> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -c y.cc
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c y.cc
y.cc:5: error: a cast to a type other than an integral or enumeration type
cannot appear in a constant-expression
Now, in contrast to the claim in PR 10922, I can't find a place in the standard
that would mandate that the result of offsetof is an integer constant
expression. 18.1.5 only says that it can only be applied to POD types, which
certainly is the case here. However, it might be a QoI issue to really
let the result be an integral constant.
W.
PS: The expansion of offsetof yields here:
(reinterpret_cast <size_t> (&reinterpret_cast <char &>(static_cast <S *> (0)->j)));
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
@ 2003-06-03 2:29 ` rwgk@yahoo.com
2003-06-03 13:48 ` bangerth@ices.utexas.edu
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rwgk@yahoo.com @ 2003-06-03 2:29 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
------- Additional Comments From rwgk@yahoo.com 2003-06-03 02:29 -------
ISO/IEC 9899:1999 (E)
7.17 Common definitions <stddef.h>
3 The macros are
NULL
which expands to an implementation-defined null pointer
constant; and offsetof(type, member-designator) which
expands to an integer constant expression that has type
^^^^^^^^^^^^^^^^^^^^^^^^^^^
size_t, the value of which is the offset in bytes, to the
structure member (designated by member-designator), from
the beginning of its structure (designated by type). The
type and member designator shall be such that given
static type t;
then the expression &(t.member-designator) evaluates to an
address constant. (If the specified member is a bit-field,
the behavior is undefined.)
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
2003-06-03 2:29 ` [Bug c++/11072] " rwgk@yahoo.com
@ 2003-06-03 13:48 ` bangerth@ices.utexas.edu
2003-06-03 16:45 ` gdr@gcc.gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: bangerth@ices.utexas.edu @ 2003-06-03 13:48 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
------- Additional Comments From bangerth@ices.utexas.edu 2003-06-03 13:48 -------
Subject: Re: [3.4 regression] Implementation of offsetof
macro
> ------- Additional Comments From rwgk@yahoo.com 2003-06-03 02:29 -------
> ISO/IEC 9899:1999 (E)
>
> 7.17 Common definitions <stddef.h>
>
> 3 The macros are
>
> NULL
>
> which expands to an implementation-defined null pointer
> constant; and offsetof(type, member-designator) which
> expands to an integer constant expression that has type
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
This provision is only in the C standard. The C++ standard has a different
wording, which I believe is intentional given that 18.1.2 says
The contents are the same as in the Standard C library header stddef.h,
with the following changes:
followed by definitions of NULL and offsetof.
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
2003-06-03 2:29 ` [Bug c++/11072] " rwgk@yahoo.com
2003-06-03 13:48 ` bangerth@ices.utexas.edu
@ 2003-06-03 16:45 ` gdr@gcc.gnu.org
2003-06-03 20:00 ` bangerth@dealii.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gdr@gcc.gnu.org @ 2003-06-03 16:45 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
gdr@gcc.gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-06-03 16:45:03
date| |
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
` (2 preceding siblings ...)
2003-06-03 16:45 ` gdr@gcc.gnu.org
@ 2003-06-03 20:00 ` bangerth@dealii.org
2003-07-02 14:30 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: bangerth@dealii.org @ 2003-06-03 20:00 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
------- Additional Comments From bangerth@dealii.org 2003-06-03 20:00 -------
See also discussion about legality of the code here:
http://gcc.gnu.org/ml/gcc-bugs/2003-06/msg00482.html
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
` (3 preceding siblings ...)
2003-06-03 20:00 ` bangerth@dealii.org
@ 2003-07-02 14:30 ` cvs-commit at gcc dot gnu dot org
2003-07-02 14:40 ` nathan at gcc dot gnu dot org
2003-07-02 14:40 ` nathan at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-02 14:30 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-07-02 14:30 -------
Subject: Bug 11072
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: nathan@gcc.gnu.org 2003-07-02 14:30:53
Modified files:
gcc : ChangeLog
gcc/ginclude : stddef.h
gcc/testsuite : ChangeLog
gcc/testsuite/g++.dg/other: offsetof2.C
Added files:
gcc/testsuite/g++.dg/other: offsetof5.C
Log message:
PR c++/11072
* ginclude/stddef.h (offsetof): Remove cast to 'char &'. Explain why.
testsuite:
PR c++/11072
* g++.dg/other/offsetof2.C: XFAIL.
* g++.dg/other/offsetof5.C: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.300&r2=2.301
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ginclude/stddef.h.diff?cvsroot=gcc&r1=1.18&r2=1.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2828&r2=1.2829
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/offsetof5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/offsetof2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
` (5 preceding siblings ...)
2003-07-02 14:40 ` nathan at gcc dot gnu dot org
@ 2003-07-02 14:40 ` nathan at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-07-02 14:40 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
------- Additional Comments From nathan at gcc dot gnu dot org 2003-07-02 14:40 -------
2003-07-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11072
* ginclude/stddef.h (offsetof): Remove cast to 'char &'. Explain why.
2003-07-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11072
* g++.dg/other/offsetof2.C: XFAIL.
* g++.dg/other/offsetof5.C: New.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/11072] [3.4 regression] Implementation of offsetof macro
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
` (4 preceding siblings ...)
2003-07-02 14:30 ` cvs-commit at gcc dot gnu dot org
@ 2003-07-02 14:40 ` nathan at gcc dot gnu dot org
2003-07-02 14:40 ` nathan at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-07-02 14:40 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11072
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From nathan at gcc dot gnu dot org 2003-07-02 14:40 -------
2003-07-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11072
* ginclude/stddef.h (offsetof): Remove cast to 'char &'. Explain why.
2003-07-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11072
* g++.dg/other/offsetof2.C: XFAIL.
* g++.dg/other/offsetof5.C: New.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-07-02 14:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03 1:34 [Bug c++/11072] New: [3.4 regression] Implementation of offsetof macro bangerth@dealii.org
2003-06-03 2:29 ` [Bug c++/11072] " rwgk@yahoo.com
2003-06-03 13:48 ` bangerth@ices.utexas.edu
2003-06-03 16:45 ` gdr@gcc.gnu.org
2003-06-03 20:00 ` bangerth@dealii.org
2003-07-02 14:30 ` cvs-commit at gcc dot gnu dot org
2003-07-02 14:40 ` nathan at gcc dot gnu dot org
2003-07-02 14:40 ` nathan 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).