Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Apr 1996 09:30:03 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        gpalmer@FreeBSD.ORG, msmith@atrad.adelaide.edu.au
Cc:        bde@zeta.org.au, freebsd-hackers@FreeBSD.ORG, jmacd@CS.Berkeley.EDU
Subject:   Re: GNU binutils port
Message-ID:  <199604242330.JAA26281@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I wouldn't be. I've got a development tree with over half those
>warnings fixed, and none of them (well, okay, one) could have done
>anything nasty. And from a quick glance through, most of the rest are
>printf() formatting warnings, as GCC can't understand some of the
>special printf contructs available in the kernel.

That's why fixing the warnings isn't a good project for beginners.
The correct fix for some of the warnings may be to change the compiler.
It _is_ the correct fix for %b format since this is a useful format.
The correct fix for `printf("%d", long_variable);' may be to silently
change the format to "%ld".  The behaviour is undefined, so it is
allowed to work.  It works by accident when sizeof(int) == sizeof(long)
but gcc issues a warning because it might not work on other systems or
with other compilers.  If gcc could guarantee that it worked on all
systems when compiled by gcc, then it would be reasonable to suppress
the warning unless the new flag -Wwarn_about_things_that_work_with_gcc_
but_may_not_work_with_other_compilers is used.

The correct fix for other warnings may be to redesign some interfaces...

>Another thing: AFAIR, GCC 2.6.3 does NOT meet the ANSI standards for
>compiler warnings & errors. I could be wrong, but if someone gets a
>commercial C compiler which DOES, and throws our kernel sources at it,
>I'll bet there'll be several more warnings (and even an error or two),
>even after removing all the GCC/GAS/GLD dependancy that we have (and I
>don't like having).

I hope there would only be a few errors detected.  However, a compiler
that does global optimizations at link time could probably detect that
some of the thousands of bogus casts would cause undefined behaviour
if they were executed, and the although it probably couldn't tell if
they were executed, the nicest thing for it to do would be to warn
about them all.

There may be any number of nonfatal warnings since ANSI doesn't
constrain warnings.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604242330.JAA26281>