This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wrong C++ warning "fix" last year


On Tuesday, March 4, 2003, at 09:18 AM, Michael Matz wrote:

Hi Matt,

your patch from
http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00112.html

Breaks the following testcase:

--------- snip ----------
class A {
public:
        char *const p;
};

class B {
public:
        B() { }
        A a;
};
--------- snap ----------

What you did, was removing a warning if the const-member-containing type
(M here) isn't an aggregate. The problem now is, that this also removes
any warning in the case above.

I've looked at gcc 3.2's behavior. My opinion:
(a) My patch was correct. gcc 3.2 did warn about this program, but gcc 3.2's warning was wrong. gcc 3.2 gave a warning for class A (you can see that the warning is for line 3), saying that class A was broken. That's false. Class A is perfectly fine. It's only class B, which uses class A incorrectly, that's broken. gcc 3.2, like 3.3 and mainline, is silent about the error in class B.
(b) A warning or error for class B, which really is broken, would be a good idea. However, that's not related to my patch. The warning/error would be for a class that inherits from an aggregate with const member variables and no constructors.


--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]