Topic: [OT] return and void
Author: edamen_0@yahoo.com ("E. Damen")
Date: Tue, 12 Nov 2002 19:58:46 +0000 (UTC) Raw View
===================================== MODERATOR'S COMMENT:
This is marginally on-topic, as compatibility between C and C++ is a
continuing concern for the community.
===================================== END OF MODERATOR'S COMMENT
"Francis Glassborow" wrote:
> In article <3dd08aad@news.toast.net>, Scott Mayo <scottm@toast.net>
> writes
> >Last I knew, this wasn't legal in C++ or C:
> >
> >extern void a(); //a, a function returning void
> >void b() { return a(); } //b calls a() and returns void
>
> It has been legal C++ for as long as the C++ Standard has existed. Of
> course that does not mean that all compilers understand that :-)
FWII: it is not valid C. Specificaly, ISO/IEC 9899:1999 (E) states the following
contraint on the return statement (6.8.4.6): A return statement with an
expression shall not appear in a function whose return type is void.
---
E. Damen
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: rmaddox@isicns.com (Randy Maddox)
Date: Wed, 13 Nov 2002 19:36:05 +0000 (UTC) Raw View
edamen_0@yahoo.com ("E. Damen") wrote in message news:<aqr2v8$gb9$1@news1.tilbu1.nb.home.nl>...
> ===================================== MODERATOR'S COMMENT:
>
> This is marginally on-topic, as compatibility between C and C++ is a
> continuing concern for the community.
>
>
> ===================================== END OF MODERATOR'S COMMENT
> "Francis Glassborow" wrote:
> > In article <3dd08aad@news.toast.net>, Scott Mayo <scottm@toast.net>
> > writes
> > >Last I knew, this wasn't legal in C++ or C:
> > >
> > >extern void a(); //a, a function returning void
> > >void b() { return a(); } //b calls a() and returns void
> >
> > It has been legal C++ for as long as the C++ Standard has existed. Of
> > course that does not mean that all compilers understand that :-)
>
> FWII: it is not valid C. Specificaly, ISO/IEC 9899:1999 (E) states the following
> contraint on the return statement (6.8.4.6): A return statement with an
> expression shall not appear in a function whose return type is void.
> ---
> E. Damen
>
You are absolutely correct, except that it is 6.8.6.4. So, while this
is valid C++, it is not valid C. So it goes.
Randy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]