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

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).