This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/27697] [4.0/4.1/4.2 Regression] incorrect warning about constness of pointer to an array in a const struct
- From: "neil at daikokuya dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 May 2006 23:17:29 -0000
- Subject: [Bug c/27697] [4.0/4.1/4.2 Regression] incorrect warning about constness of pointer to an array in a const struct
- References: <bug-27697-10744@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from neil at daikokuya dot co dot uk 2006-05-21 23:17 -------
Subject: Re: [4.0/4.1/4.2 Regression] incorrect warning about constness of
pointer to an array in a const struct
pinskia at gcc dot gnu dot org wrote:-
>
>
> ------- Comment #2 from pinskia at gcc dot gnu dot org 2006-05-21 16:15 -------
> This is also rejects valid with -pedantic-errors.
> I don't understand what is correct here so I am not going to confirm it.
If I understand correctly I think the report is correct about
validity for both C90 and C99; another front end gives
"/tmp/bar.c", line 10: error: cannot convert initializer of type "const
int (*)[10]" to type "int (*)[10]"
int (*qoox)[10] = bar.x; /* should warn */
^
"/tmp/bar.c", line 11: error: expression must be a modifiable lvalue
bar.x[0][1] = 23; /* error: asignment to const */
^
"/tmp/bar.c", line 9: warning: variable "baz" declared but not used
const int (*baz)[10] = bar.x; /* should be ok */
^
2 errors found compiling "/tmp/bar.c".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27697