This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix warning about duplicate 'const'
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: Linus Torvalds <torvalds at osdl dot org>, Thomas Schlichter <thomas dot schlichter at web dot de>, Andrew Morton <akpm at osdl dot org>, linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- Date: 10 Mar 2004 09:10:49 +0100
- Subject: Re: [PATCH] fix warning about duplicate 'const'
- Organization: Integrable Solutions
- References: <200403090043.21043.thomas.schlichter@web.de><20040308161410.49127bdf.akpm@osdl.org><Pine.LNX.4.58.0403081627450.9575@ppc970.osdl.org><200403090217.40867.thomas.schlichter@web.de><Pine.LNX.4.58.0403081728250.9575@ppc970.osdl.org><20040310054918.GB4068@twiddle.net>
Richard Henderson <rth@twiddle.net> writes:
| On Mon, Mar 08, 2004 at 05:32:11PM -0800, Linus Torvalds wrote:
| > Also, I'm not convinced this isn't a gcc regression. It would be stupid to
| > "fix" something that makes old gcc's complain, when they may be doing the
| > right thing.
|
| Problem is, that we're supposed to complain for
|
| const const int x;
| and
| typedef const int t;
| const t x;
If I can help with an existing pratice, in C++ the former is
invalid and the second is valid -- the extra const is just silently
ignored. Therefore, in C++ land the construct
| const int a;
| const __typeof(a) x;
would be accepted because __typeof__ acts like an unnamed typedef[*].
(And in effect, g++ will accept the code -- assuming you abstract over
initializers). So, it does not look like an innovation here.
I don't know whether this should be another case for "C is different
from C++".
[*] Yes, an alias that does not introduce a name is strange alias, but
that is what __typeof__ does.
-- Gaby