comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Another ammunition
Date: Mon, 06 Jan 2003 12:39:50 -0500
Date: 2003-01-06T12:39:50-05:00	[thread overview]
Message-ID: <3E19BF66.2050506@cogeco.ca> (raw)
In-Reply-To: vjHR9.27734$p_6.2299935@bgtnsc04-news.ops.worldnet.att.net

David Thompson wrote:
> Warren W. Gay VE3WWG <ve3wwg@cogeco.ca> wrote :
>>Jean-Pierre Rosen wrote:
>>
>>>"Eric G. Miller" <egm2.NOSPAM@jps-NOSPAM.net> a �crit dans le message news:
>>
> IpfQ9.4953
> ....
> 
>>>>You're right, but I'm sure gcc could have immediately diagnosed the
>>>>problem had you turned up the warnings ("conflicting types for...",
>>>
> "previous
> 
>>>>declaration of ...").
>>>
>>>Warnings were on, he just overlooked them....
> 
> Could have (and did) *IF* the same declaration is visible at
> all relevant locations, typically by #include'ing the same .h file.
> If you just write out a wrong declaration of foo in bar.c, gcc can't
> catch it (though a good lint can).  Also, if you mistakenly #include
> a wrong .h file (such as from a wrong subtree) gcc can't catch it,
> although this is unlikely in simple student projects.
> (A C implementation *could* legally and practially do
> the kinds of whole-program or at least cross-unit checks
> Ada requires and GNAT does, but they don't, not even gcc.)
> ....
>>Things may be different now, but I once had a long email discussion
>>with one of the folks about whether a missing return "type" should
>>be a warning or not (it should actually be an error). At the time,
>>you had to specify a compile option to make a declaration like:
>>
>>foo() { ... }
>>
>>return a warning. ...
> 
> (That's a definition, not just a declaration.
> /*int*/ foo () ; is a typical "external" declaration.)

Sigh, yes, everyone knows this. Even pure undefiled Ada programmers
know this, I expect. ;-)

> According to all C standards before C99 (K&R and C89) it *is*
> legal and so can't conformingly be an error.  

Fine, but it should be a warning.

> With C99 it is a
> required diagnostic and could well be an error, but won't because
> implementors don't want to break vast masses of existing legal
> and supported code.  I agree it should be a warning, 

Agreed. It _should_ be at least a warning.

> but whether
> it's on by default doesn't matter much to me, since I always end up
> with some mechanism (makefile, script, envvar) for setting flags
> anyway, and if this needs an entry in there it's no real trouble.
> 
> --
> - David.Thompson 1 now at worldnet.att.net

The point is, is that a lot of other projects and even team members
fail to include the support for this "warning". If it were on by
default, there would be uncounted number of hours saved each year
by programmers who instead spend the time debugging a problem
related to this issue.  I've seen this time and again, even though
my team members know about it.

It is not enough to say "it is not an issue because I do this...".
It is an issue, that could be fixed once and for all.
Even a warning doesn't guarantee that it will be noticed and
fixed -- but it greatly increases the odds!

However, the best solution of all is to use Ada instead, and only
rely on C like an assembly level layer, when required ;-)

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  reply	other threads:[~2003-01-06 17:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-31 10:23 Another ammunition Jean-Pierre Rosen
2002-12-31 11:43 ` Eric G. Miller
2002-12-31 12:57   ` Jean-Pierre Rosen
2002-12-31 16:23     ` Alexander Schreiber
2003-01-02  6:55       ` AG
2003-01-01 16:58         ` Alexander Schreiber
2003-01-07 12:54           ` Peter Hermann
2003-01-07 13:21           ` Richard Riehle
2003-01-11 18:29             ` Alexander Schreiber
2003-01-13  2:11               ` u.r. faust
2003-01-12 12:44                 ` Larry Kilgallen
2003-01-14  1:24                   ` Georg Bauhaus
2003-01-03  9:50         ` Jean-Pierre Rosen
2003-01-03 15:24         ` Stephen Leake
2002-12-31 16:40     ` Warren W. Gay VE3WWG
2003-01-04 20:17       ` David Thompson
2003-01-06 17:39         ` Warren W. Gay VE3WWG [this message]
2003-01-06 20:50           ` Stephen Leake
2003-01-06 22:16             ` Warren W. Gay VE3WWG
2003-01-07 18:37               ` Stephen Leake
2003-01-07 21:55                 ` Warren W. Gay VE3WWG
2003-01-01  9:05 ` Michael Erdmann
2003-01-07 13:03   ` Peter Hermann
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox