This is the mail archive of the gcc-bugs@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]

Re: c++ test


Alexandre Oliva wrote:
> 
> On Nov  9, 2000, Eric Christopher <echristo@cygnus.com> wrote:
> 
> > test.cc:17: invalid use of type decl `struct DATA' as expression
> > test.cc:17: parse error before ':' token
> 
> This is indeed wrong.
> 
> > test.cc: In function `int main ()':
> > test.cc:17: passing `const DATA' as `this' argument of `DATA::~DATA ()'
> > discards qualifiers
> 
> But this error message looks right to me, unless there's some rule I
> don't remember that allows a destructor to be *explicitly* called on a
> const object (it can certainly be called *implicitly*).
> 

Yep.  I found it not too long ago (at least that's how I'm interpreting
it ;)

From 9.4.5

Constructors (12.1) and destructors (12.4) shall not be declared const,
volatile, or const volatile.  [Note:  However, these functions can be
invoked to create and destroy objects with ev-qualified types, see
(12.1) and (12.4).

From 12.4.2

A destructor is used to destroy objects of its class type.  A destructor
takes no parameters, and no return type can be specified for it (not
even void).  The address of a destructor shall not be taken.  A
destructor shall not be static.

A destructor can be invoked for a const, volatile, or const volatile
object.  A destructor shall not be declared const, volatile, or const
volatile (9.3.2).  const and volatile semantics (7.1.5.1) are not
applied on an object under destruction.  Such semantics stop being into
effect once the destructor for the most derived object (1.8) starts.


Looks good to me yes?

-eric

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