---------- Forwarded message ----------
From: Igor Bukanov <[EMAIL PROTECTED]>
Date: Oct 31, 2006 9:48 PM
Subject: Re: return void from void function is allowed.
To: Mike Stump <[EMAIL PROTECTED]>


On 10/31/06, Mike Stump <[EMAIL PROTECTED]> wrote:

This is valid in C++.

My copy of 1997 C++ public draft contains:

6.6.3  The return statement
...
2 A return statement without an expression can be used only in functions
 that  do not return a value, that is, a function with the return value
 type   void,   a   constructor   (_class.ctor_),   or   a   destructor
 (_class.dtor_).   A  return  statement  with an expression can be used
 only in functions returning a value; the value of  the  expression  is
 returned  to  the caller of the function.  If required, the expression
 is implicitly converted to the return type of the function in which it
 appears.   A return statement can involve the construction and copy of
 a temporary object (_class.temporary_).  Flowing  off  the  end  of  a
 function  is  equivalent  to  a  return with no value; this results in
 undefined behavior in a value-returning function.

My reading of that is C++ does not allow return void-expression from
void function. Was it changed later?

And final thought, wrong mailing list...   gcc-help would have been
better.

I thought bugs in GCC can be discussed here. Sorry if it is a wrong assumption.

Regards, Igor

Reply via email to