public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41039]  New: Member reordering rule is overly strict
@ 2009-08-12  4:21 coppro at users dot sf dot net
  2009-08-12  6:16 ` [Bug c++/41039] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: coppro at users dot sf dot net @ 2009-08-12  4:21 UTC (permalink / raw)
  To: gcc-bugs

The check for declarations that could, if reordered within a class, alter the
meaning of that class (and thus be ill-formed) is overly restrictive.
Specifically, it bans any declaration that might cause such an issue, while a
program is ill-formed only if the reordering would actually cause an ambiguity.

The following is not valid

struct foo { };
struct bar {
  foo f;
  foo foo();
}

because if you rearrange the definitions within bar, the program's meaning
might change.

The following, however, is

struct foo { };
struct bar {
  foo foo();
}

because there is nothing to reorder, so the meaning of bar cannot possibly
change.


-- 
           Summary: Member reordering rule is overly strict
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: coppro at users dot sf dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/41039] Member reordering rule is overly strict
  2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
@ 2009-08-12  6:16 ` pinskia at gcc dot gnu dot org
  2009-08-12  6:27 ` coppro at users dot sf dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-08-12  6:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-08-12 06:15 -------
> because there is nothing to reorder, so the meaning of bar cannot possibly
> change.

But the rule is not designed that way IIRC.  Even if it is too strict I think
that is the correct way of doing things.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/41039] Member reordering rule is overly strict
  2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
  2009-08-12  6:16 ` [Bug c++/41039] " pinskia at gcc dot gnu dot org
@ 2009-08-12  6:27 ` coppro at users dot sf dot net
  2009-08-12  9:28 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: coppro at users dot sf dot net @ 2009-08-12  6:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from coppro at users dot sf dot net  2009-08-12 06:26 -------
[basic.scope.class]:
3) If reordering member declarations in a class yields an alternate valid
program under (1) and (2), the program is ill-formed, no diagnostic is
required.

Otherwise, the program is well-formed, and while a warning is nice, it's not
correct for GCC to reject this code.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/41039] Member reordering rule is overly strict
  2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
  2009-08-12  6:16 ` [Bug c++/41039] " pinskia at gcc dot gnu dot org
  2009-08-12  6:27 ` coppro at users dot sf dot net
@ 2009-08-12  9:28 ` rguenth at gcc dot gnu dot org
  2009-08-12  9:41 ` jwakely dot gcc at gmail dot com
  2009-08-14  5:41 ` coppro at users dot sf dot net
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-12  9:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-08-12 09:28 -------
Use -fpermissive.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/41039] Member reordering rule is overly strict
  2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
                   ` (2 preceding siblings ...)
  2009-08-12  9:28 ` rguenth at gcc dot gnu dot org
@ 2009-08-12  9:41 ` jwakely dot gcc at gmail dot com
  2009-08-14  5:41 ` coppro at users dot sf dot net
  4 siblings, 0 replies; 6+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-08-12  9:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jwakely dot gcc at gmail dot com  2009-08-12 09:41 -------
I think maybe the second example is rejected because of 2) not 3)

2) A name N used in a class S shall refer to the same declaration in its
context and when re-evaluated in the
completed scope of S. No diagnostic is required for a violation of this rule.

'foo' is used in the class, but in the completed scope which includes the
function body of S::foo() 'foo' refers to the member function.

If you don't want to use -fpermissive you can convince gcc to compile it by
referring to the type as '::foo' because in that case the name always refers to
the global type even in the completed scope.

struct foo { };
struct bar {
  ::foo foo();
};


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/41039] Member reordering rule is overly strict
  2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
                   ` (3 preceding siblings ...)
  2009-08-12  9:41 ` jwakely dot gcc at gmail dot com
@ 2009-08-14  5:41 ` coppro at users dot sf dot net
  4 siblings, 0 replies; 6+ messages in thread
From: coppro at users dot sf dot net @ 2009-08-14  5:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from coppro at users dot sf dot net  2009-08-14 05:41 -------
Jonathan Wakely appears to be correct. My apologies!


-- 

coppro at users dot sf dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41039


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-14  5:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-12  4:21 [Bug c++/41039] New: Member reordering rule is overly strict coppro at users dot sf dot net
2009-08-12  6:16 ` [Bug c++/41039] " pinskia at gcc dot gnu dot org
2009-08-12  6:27 ` coppro at users dot sf dot net
2009-08-12  9:28 ` rguenth at gcc dot gnu dot org
2009-08-12  9:41 ` jwakely dot gcc at gmail dot com
2009-08-14  5:41 ` coppro at users dot sf dot net

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