This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49748] char * const * cannot be assigned to char const * const *
- From: "tim.ruehsen at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 23 Feb 2012 14:12:00 +0000
- Subject: [Bug c/49748] char * const * cannot be assigned to char const * const *
- Auto-submitted: auto-generated
- References: <bug-49748-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49748
Tim Ruehsen <tim.ruehsen at gmx dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tim.ruehsen at gmx dot de
--- Comment #3 from Tim Ruehsen <tim.ruehsen at gmx dot de> 2012-02-23 14:12:00 UTC ---
Just to clarify it and to add a complete program.
#### x.c ####
void f(const char *const *args) {}
int main(int argc, char **argv) {
f(argv);
return 0;
}
####
Compiling with g++ (4.6.2) will do without warning.
Compiling with gcc (4.6.2) gives:
x.c: In function 'main':
x.c:4:2: warning: passing argument 1 of 'f' from incompatible pointer type
[enabled by default]
x.c:1:6: note: expected 'const char * const*' but argument is of type 'char **'
This is somewhat annoying when trying to harden older C sources with
-Wwrite-strings.
One has to insert (very) many casts to avoid the above warning.
This is much work that could be avoided by an apropriate -W option.