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]

Re: Proposal: Make "int format, different type arg" an error, nota warning


Maybe I didn't make myself clear.  On a 64-bit machine, when the printf
expects a 32bit argument, and a 64bit argument is pushed on the stack,
this is most likely an error.  I'm just asking that non-matching of
the size of arguments passed versus arguments expected be treated as an
error; this does not affect 32-bit code, where these things do match in
my example.

Brad

> From kamil@wins.uva.nl  Fri Jun  2 15:32:35 2000
> On Thu, 1 Jun 2000, Brad Lucier wrote:
> 
> > When you have something like
> > 
> > printf ("%d\n", (HOST_WIDE_INT) &i);
> > 
> > on the alpha, then the format is for a 32-bit int, while the actual
> > argument is a 64bit long.
> [snip]
> > These often indicate serious enough problems that I think it would be
> > better that they be errors rather than warnings.
> 
> I don't see the point. The compiler already provides suitable diagnostics.
> So what that it's only a warning - it serves its purpose. If the
> programmer knows h[is|er] work, and the code in question is supposed to be
> portable, it will be fixed.
> 
> I think it would be arrogant for the compiler to reject such code on
> 32-bit platforms, where its behaviour is perfectly well defined. It would
> only upset the majority of users, who still use 32-bit platforms.

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