This is the mail archive of the gcc-help@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: Inconsisten error messages on const pointers


Jonathon;

There is a indentation in my forhead where I said "I knew that".

thanks
art



----- Original Message ----
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Arthur Schwarz <aschwarz1309@att.net>
Cc: gcc-help@gcc.gnu.org
Sent: Sun, October 14, 2012 2:20:21 PM
Subject: Re: Inconsisten error messages on const pointers

On 14 October 2012 21:33, Arthur Schwarz wrote:
> In the example below the following two statements seem to be inconsistent:
>   1:   cout << "      " << endl << cell1->dump();
>   2:   this->message += cell1->dump();
>
> 1: produces the error message
>      SlipException.h: In member function âvoid slip::SlipException::log()â:
>     In file included from SlipCell.h:49:0,
>                  from SlipDatum.h:269,
>                  from SlipOp.h:22,
>                  from SlipStringOp.h:12,
>                  from SlipStringOP.cpp:11:
>     SlipException.h:29:79: error: passing âconst slip::SlipCellBaseâ as âthisâ
> argument of âvirtual std::string slip::SlipCellBase::dump()â discards 
>qualifiers
>
> With 2: there is no diagnostic message. Any reason why?

In 1 'cell1' refers to this->cell1 which is a const SlipCellBase*, so
you can't call the non-const dump function

In 2 'cell1' refers to the constructor argument, which has type
SlipCellBase*, so you can call the non-const function.


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