rreturning void

Jason Merrill jason@cygnus.com
Wed Jun 17 18:53:00 GMT 1998


>>>>> David C Binderman <dcb@pncl.co.uk> writes:

> Hello there,

> The following code used to not compile, but on egcs-980615 it does.

> void
> function() {
> 	int var = 0;
> 	return (void) ++var;
> }

> I think that this code should not be compilable, and would like to find
> out which bit of the ISO spec says this is ok.

This was added recently, for templates:

  6.6.3 - The return statement [stmt.return]

  3- A return statement with an expression of type `cv void' can be used
  only in functions with a return type of cv void; the expression is
  evaluated just before the function returns to its caller.

Jason



More information about the Gcc-bugs mailing list