[cfe-dev] Fixing selector types on the GNU runtime
David Chisnall
csdavec at swansea.ac.uk
Wed Jan 21 04:18:05 PST 2009
On 21 Jan 2009, at 03:14, Mike Stump wrote:
> So, what are you interested in, the theoretics of hard core
> pedantictry or the engineering realities of having FreeBSD be warning
> free?
I'm interested in fixing the warning only in as far as the warning
indicates potentially unsafe code. The code, as written and according
to the language specification, says pass a zero integer value of some
indeterminate size to terminate the variadic function. The callee
expects a zero pointer value. This is categorically wrong. If some
compilers on some architectures do the right thing, then that's a nice
bonus. On x86/FreeBSD, the compiler does the right thing (since NULL
is a pointer-sized int) but it warns that this is a coincidence.
The #ifdef block you suggest makes the warning go away on FreeBSD/x86,
but this is not a platform where the real problem actually occurs,
just one which notices that the code is wrong and issues a warning.
Warning that the code does not say what you think it does is not a
bug, it is a (useful) feature.
The diff I submitted does the right thing, according to the standard.
If this is not what you want, then please update the coding
conventions to specify this exemption. As it stands, my diff will
avoid real issues on platforms like Win64, where 0 and 0L, the two
suggested definitions of NULL from the standard, are both smaller than
pointers. I have variadic function calls in this file with more
pointer arguments than there are integer registers on x86-64 for
argument passing, so the 0 will be passed on the stack on this
platform and not extended to 64-bits.
Honestly, the amount of effort people have put in to arguing against
fixing this one file is less than the amount of effort it would have
taken to make the change everywhere in LLVM. I put these changes in
with the fixing the type conversion diff because I assumed there would
be no debate about fixing incorrect code. It seems I was wrong, so
have attached a diff that only fixes the type conversion error, and
leaves the unsafe variadic function calls in.
David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090121/9efccadc/attachment.obj>
-------------- next part --------------
More information about the cfe-dev
mailing list