[NTLUG:Discuss] Thinking ALPHA
Steve Baker
sjbaker1 at airmail.net
Sun Sep 26 11:57:24 CDT 1999
cbbrowne at godel.brownes.org wrote:
> I always found it something of a convenience that Pascal would always "puke"
> on that sort of thing; 'tis quite useful to *know* that you've not initialized
> a variable.
Well, C/C++ compilers *try* to tell you - but programmers can get pretty
devious about how they do or don't initialise things:
int x ;
if ( y ) x = 1 ;
if ( !y ) x = 2 ; /* Ugh! */
z = x ;
...x is always initialised - but the compiler will probably still
complain
that it isn't.
int x ;
do_something ( & x ) ;
z = x ;
...the compiler can't tell whether 'x' is initialised by 'do_something'
or not...it's a literal impossibility because the code for
'do_something'
may not even have been written at the time when the offending snippet
is compiled.
So, it's pretty hard for a compiler to figure it out with any certainty
and (IMHO) people *hate* warning messages about things that are
perfectly
good code more than they hate the compiler not warning about things that
are marginally wrong.
It's a hard call for the compiler writer.
It's not a distinction between Pascal and C/C++ - it's a distinction
between compilers. The SGI IRIX compiler complains about an entirely
different set of problems than the GNU compiler - and those are
different
again from the problems that the M$VC compiler will pick up. Even after
my Tux code had been compiled by all three of those, there were still
warning messages popping up out of the Apple C++ compiler on the Mac
and Borland C++ under Windoze.
To echo the words of our speaker at the meeting yesterday: Porting code
shows up errors...and that's because (in part) the more compilers look
at your code, the more things are going to get warned about.
--
Steve Baker http://web2.airmail.net/sjbaker1
sjbaker1 at airmail.net (home) http://www.woodsoup.org/~sbaker
sjbaker at hti.com (work)
More information about the Discuss
mailing list