Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > gcc bug ?

Thread Tools

gcc bug ?

Harald van Dijk
Posts: n/a
On Tue, 20 May 2008 23:27:18 +0200, Pietro Cerutti wrote:
> Harald van Dijk wrote:
>> The return statement
>> Constraints
>> 1 A return statement with an expression shall not appear in a function
>> whose return type is void. A return statement without an expression
>> shall only appear in a function whose return type is void.
>> This disallows
>> void f(void);
>> void g(void) {
>> return f();
>> }
>> because while f() can be argued not to have a value, it is still an
>> expression.

> Would you like to see my answer to Keith and try to elaborate that?

You already have your answer, but here's another approach:

The syntax of the return statement is:

return expression[opt] ;

This means there are two forms of the return statement. They are:

return ;
return expression ;

If f() is an expression, return f(); violates If f() is not an
expression, return f(); is a syntax error. So it doesn't really matter,
either way, the compiler must complain.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gcc 3.4.X to Gcc 4.1.X upgrading kas C++ 1 04-22-2010 08:56 PM
GCC 3.4.3 and GCC 4.1.2 ashnin C++ 1 07-07-2008 01:10 PM
Template construction in old gcc 3.3.3 does not compile in gcc 3.4.4 C++ 5 09-17-2005 12:27 AM
gcc 2.95 and gcc 3.2 C++ 8 03-16-2005 02:34 AM
C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1 Kevin P. Fleming C Programming 2 11-06-2003 05:15 AM