------- Additional Comments From joseph at codesourcery dot com 2004-11-10 01:15 ------- Subject: Re: Warning not legitimate
On Wed, 10 Nov 2004, manus at eiffel dot com wrote: > Ok, so why don't you generate the warning only when it makes sense. In my > original case, I was passing a char and tell the C compiler it was a function > pointer expecting a char. In this scenario it should not produce any warning. There is a limit to how much we care about code with undefined behavior on execution. What type you pass in the source code is a red herring; if you cast to a prototype type then the arguments will be getting converted to that type, including if you'd passed a float argument. We aim for the front end to pass down type-consistent code to the rest of the compiler (which ideally would never need to call back into the earlier parts of the compiler); where the standard requires type-inconsistent code to be compiled but gives it execution-time undefined behavior, the only sensible consistent structure for the rest of the compiler involves an abort in place of the nonsensical code. > If you have incompatible types (such as int where you expect a float/double) > then I'm ok that you generate a warning (although I would prefer an error > since > the generated code is incorrect). Remember DR#109: A conforming implementation must not fail to translate a strictly conforming program simply because *some* possible execution of that program would result in undefined behavior. The undefined behavior is only on execution, so the program must be accepted. Because its execution is nonsensical - has no meaning whatever - an abort is generated. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18411