On Tue, Jul 01, 2008 at 11:37:05AM +0000, Joseph S. Myers wrote:
> On Tue, 1 Jul 2008, Michael Meissner wrote:
> 
> > On Tue, Jul 01, 2008 at 11:50:58AM +0200, Denys Vlasenko wrote:
> > > On Tuesday 01 July 2008 09:24, Sajish V wrote:
> > > > Thanks for the reply, Denys.
> > > > My question was, why doesn't gcc catch it during compilation? It is 
> > > > clear
> > > > that we are trying to free a variable from stack. Shouldn't gcc flag an
> > > > error for this during compilation?
> > 
> > It could.  Nobody has written the code to do so, and as they say patches are
> > welcome (assuming you have done the paperwork to legally contribute to GCC).
> > Have you filed a feature request via bugzilla so that it can be tracked?
> 
> An error is inappropriate; undefined behavior only occurs on execution of 
> the call to free, not on compilation of the program.  A warning would be 
> fine (as would converting the call to free into an abort).

True enough from a standards point of view.  Obviously having a warning would
allow some invalid code to be detected at compilation time.

-- 
Michael Meissner
email: [EMAIL PROTECTED]
http://www.the-meissners.org

Reply via email to