Re: -Wcast-qual and casting away

2009-05-21 Thread Gabriel Dos Reis
On Thu, May 21, 2009 at 11:11 AM, Ian Lance Taylor wrote: > Richard Guenther writes: > >> On Thu, May 21, 2009 at 1:50 PM, Andreas Schwab >> wrote: >>> Ian Lance Taylor writes: >>> Consider this C/C++ program: extern void **f1(); void f2(const char *p) { *(const void **)f1(

Re: -Wcast-qual and casting away

2009-05-21 Thread Gabriel Dos Reis
On Thu, May 21, 2009 at 5:20 AM, Richard Guenther wrote: > On Thu, May 21, 2009 at 7:10 AM, Ian Lance Taylor wrote: >> Consider this C/C++ program: >> >> extern void **f1(); >> void f2(const char *p) { *(const void **)f1() = p; } >> >> If I compile this program with g++ -Wcast-qual, I get this: >

Re: -Wcast-qual and casting away

2009-05-21 Thread Gabriel Dos Reis
On Thu, May 21, 2009 at 12:10 AM, Ian Lance Taylor wrote: > Consider this C/C++ program: > > extern void **f1(); > void f2(const char *p) { *(const void **)f1() = p; } > > If I compile this program with g++ -Wcast-qual, I get this: > > foo2.cc:2: warning: cast from type ‘void**’ to type ‘const voi

Re: -Wcast-qual and casting away

2009-05-21 Thread Ian Lance Taylor
Richard Guenther writes: > On Thu, May 21, 2009 at 1:50 PM, Andreas Schwab wrote: >> Ian Lance Taylor writes: >> >>> Consider this C/C++ program: >>> >>> extern void **f1(); >>> void f2(const char *p) { *(const void **)f1() = p; } >>> >>> If I compile this program with g++ -Wcast-qual, I get th

Re: -Wcast-qual and casting away

2009-05-21 Thread Ian Lance Taylor
"Joseph S. Myers" writes: > On Wed, 20 May 2009, Ian Lance Taylor wrote: > >> All that aside, I can't think of any reason that the C and C++ frontends >> should be different in this regard. Does anybody want to make an > > There's the fairly obvious reason that C and C++ have different rules on

Re: -Wcast-qual and casting away

2009-05-21 Thread Dave Korn
Ian Lance Taylor wrote: > Consider this C/C++ program: > > extern void **f1(); > void f2(const char *p) { *(const void **)f1() = p; } > > If I compile this program with g++ -Wcast-qual, I get this: > > foo2.cc:2: warning: cast from type ‘void**’ to type ‘const void**’ casts away > qualifiers >

Re: -Wcast-qual and casting away

2009-05-21 Thread Sebastian Redl
Richard Guenther wrote: > On Thu, May 21, 2009 at 1:50 PM, Andreas Schwab wrote: > >> Ian Lance Taylor writes: >> >> >>> Consider this C/C++ program: >>> >>> extern void **f1(); >>> void f2(const char *p) { *(const void **)f1() = p; } >>> >>> If I compile this program with g++ -Wcast-qual

Re: -Wcast-qual and casting away

2009-05-21 Thread Andreas Schwab
Richard Guenther writes: > For > > extern const char **f1(); > void f(char *p) > { > *(char **)f1() = p; > } > > it warns with > > t.C: In function ‘void f(char*)’: > t.C:4: warning: cast from type ‘const char**’ to type ‘char**’ casts > away constness > > which makes sense. This is actually a

Re: -Wcast-qual and casting away

2009-05-21 Thread Richard Guenther
On Thu, May 21, 2009 at 1:50 PM, Andreas Schwab wrote: > Ian Lance Taylor writes: > >> Consider this C/C++ program: >> >> extern void **f1(); >> void f2(const char *p) { *(const void **)f1() = p; } >> >> If I compile this program with g++ -Wcast-qual, I get this: >> >> foo2.cc:2: warning: cast fr

Re: -Wcast-qual and casting away

2009-05-21 Thread Joseph S. Myers
On Wed, 20 May 2009, Ian Lance Taylor wrote: > All that aside, I can't think of any reason that the C and C++ frontends > should be different in this regard. Does anybody want to make an There's the fairly obvious reason that C and C++ have different rules on implicit conversions involving cons

Re: -Wcast-qual and casting away

2009-05-21 Thread Andreas Schwab
Ian Lance Taylor writes: > Consider this C/C++ program: > > extern void **f1(); > void f2(const char *p) { *(const void **)f1() = p; } > > If I compile this program with g++ -Wcast-qual, I get this: > > foo2.cc:2: warning: cast from type ‘void**’ to type ‘const void**’ casts away > qualifiers I

Re: -Wcast-qual and casting away

2009-05-21 Thread Richard Guenther
On Thu, May 21, 2009 at 7:10 AM, Ian Lance Taylor wrote: > Consider this C/C++ program: > > extern void **f1(); > void f2(const char *p) { *(const void **)f1() = p; } > > If I compile this program with g++ -Wcast-qual, I get this: > > foo2.cc:2: warning: cast from type ‘void**’ to type ‘const void