This is the mail archive of the gcc@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: [RFC] warning: initialization discards qualifiers from pointertarget type


Devang Patel wrote:
On Apr 18, 2005, at 6:29 PM, James E Wilson wrote:
I notice that these are pedwarns,
In that case, we can enable it only when -pedantic is used (like many pedwarns) ?

Consider this small modification to your testcase.


const char *a( void )
{
  return "abc";
}

int main( void )
{
  char *s = a();
  s[0] = 'c';
  return 0;
}

This will core dump when run on any system that write-protects read-only data. The only warning that you will get from gcc is the one that you are asking us to disable. This is the reason for the warning, as it is necessary to detect unsafe code like this.

I don't believe this warning should depend on -pedantic, as it is doing something useful. I think a special -Wno- option makes more sense.

I was going to ask why you need this change, but you already answered that question. If I had a customer getting 55k+ warnings, I'd want to add an option for them also.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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