public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6262: Incorrect error message reported when applying sizeof() to non-static class member
@ 2002-04-11 11:56 neil
  0 siblings, 0 replies; 2+ messages in thread
From: neil @ 2002-04-11 11:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6262
>Category:       c++
>Synopsis:       Incorrect error message reported when applying sizeof() to non-static class member
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 11 11:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     neil@neilpearce.com
>Release:        unknown-1.0
>Organization:
>Environment:
SunOS 5.8 Generic_108528-01 sun4u sparc SUNW,Ultra-5_10
Reading specs from /usr/local/gcc3.0.4/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/specs
Configured with: ../gcc-3.0.4/configure --exec-prefix=/usr/local/gcc3.0.4
Thread model: posix
gcc version 3.0.4
>Description:
When using sizeof() on a non-static class member,
the error message reported differs depending
on the context in which the code appears.

GCC 3.0.4 gives an incorrect error message when
this is attempted within a constructor
>How-To-Repeat:
Individually attempt to compile the two sources
below, and examine the error messages returned by
GCC 3.0.4 

----------

#include <iostream>

struct X {
  char x[1];
};

struct Y {
  Y() { std::cout << sizeof(X::x); }
}

Under GCC 3.0.4, compiliation of the above results in 
z.cc: In constructor `Y::Y()':
z.cc:8: cannot convert a pointer of type `Y' to a pointer of type `X'

----------

#include <iostream>

struct X {
  char x[1];
};

int main() {
  std::cout << sizeof(X::x);
}

Under GCC 3.0.4, compilation of the above results in
z.cc:4: member `X::x' is non-static but referenced as a static member
z.cc:8: at this point in file

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/6262: Incorrect error message reported when applying sizeof() to non-static class member
@ 2002-08-15  9:36 gdr
  0 siblings, 0 replies; 2+ messages in thread
From: gdr @ 2002-08-15  9:36 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gdr, neil, nobody

Synopsis: Incorrect error message reported when applying sizeof() to non-static class member

Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Thu Aug 15 04:54:46 2002
Responsible-Changed-Why:
    Analyzed
State-Changed-From-To: open->feedback
State-Changed-By: gdr
State-Changed-When: Thu Aug 15 04:54:46 2002
State-Changed-Why:
    GCC-3.3 display a different diagnostic; it says:
        type `X' is not a base type for type `Y'
    instead of the previous confusing "cannot convert pointer".
    Isn't that a better diagnostic?

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6262


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

end of thread, other threads:[~2002-08-15 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-11 11:56 c++/6262: Incorrect error message reported when applying sizeof() to non-static class member neil
2002-08-15  9:36 gdr

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