This is the mail archive of the 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: pointer <-> integer round-up

   From: (Robert Dewar)
   <<The aim is not to make the code more portable.
     The aim is to supress a compiler warning.

   Sorry, I still don't understand, why would you want a portable way of
   suppressing a warning about a construct that is inherently non-portable
   and may fail on some targets?

Because for certain uses of the construct, on platforms where the
warning is given, it is spurious and leads to confusion and wasted
effort if given unconditionally.  At the same time, there is no
portable[1], side-effectless change to the code that can be used to
eliminate warnings in the spurious cases.

A warning like "control reaches end of non-void function" can also be
spurious, but for that warning, there is an easy work-around that is
so close to side-effectless as to make nevermind.

Maybe a general rule can be stated:

	For any warning given for legal constructs, there must be
	either a (strongly) portable code change that can eliminate
	the warning without alterning the meaning of the program,
	or an option which disables that warning (but no others).

With such a rule, you can adopt a coding style discipline that
leverages the existing warning facilities to good effect and gives a
useful meaning to "compiles cleanly with such-and-such options".


[1] fjh has pointed out that there is a workaround that is portable to 
    all platforms GCC currently supports;  I'm using the word
    "portable" in a larger sense, in part because GCC is not the only
    compiler I want to think about while writing code.

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