This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33425] GCC Compiles C++ program containing value-returning functions that don't return a value
- From: "bobby_miesen at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Sep 2007 22:21:23 -0000
- Subject: [Bug c++/33425] GCC Compiles C++ program containing value-returning functions that don't return a value
- References: <bug-33425-15094@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from bobby_miesen at yahoo dot com 2007-09-13 22:21 -------
Subject: Re: GCC Compiles C++ program containing value-returning
functions that don't return a value
The reference I'm reading ("The C++ Programming Language, 3rd ed.", pp.
148) says in section 7.3, "A value must be returned from a function that
is not declared void
...
int f1() { } // error: no value returned"
So, according to a well-respected reference written by the author of
the C++ language, that statement, if I'm interpreting the meaning of
Stroustrup's comment correctly, should not be compiled by a C++
compiler. If that is true, then it should be caught by the compiler as
an error rather than a (optional) warning. But according to what you're
saying, it should only be undefined (and dangerous) behavior.
Whenever you get a chance, could you let me know where you are
getting your information from? I'd like to take a look at it myself so
we can both be on the same page.
Thanks in advance.
pinskia at gcc dot gnu dot org wrote:
> ------- Comment #1 from pinskia at gcc dot gnu dot org 2007-09-13 20:57 -------
> main.cpp: In function 'bool Func1(int)':
> main.cpp:43: warning: control reaches end of non-void function
>
> Actually in C++, this is only undefined behavior.
>
>
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33425