This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: returning unconstructed objects - bug or a feature?
- From: Jakob Oestergaard <jakob at unthought dot net>
- To: fiend at Dartmouth dot EDU
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Apr 2003 11:16:49 +0200
- Subject: Re: returning unconstructed objects - bug or a feature?
- References: <10388611@newdancer.Dartmouth.EDU>
On Thu, Apr 17, 2003 at 04:39:16AM -0400, Nebojsa Sabovic wrote:
> Hello,
>
> I noticed that when the return statement is omitted from the function that is
> supposed to return an object, no constructor is invoked on the object. It
> seemed logical to me that the default constructor should be invoked.
Such code is broken.
Always compile with -Wall (no discussion) - you may want to compile with
"-Wall -Werror" (that's a matter of taste).
> For
> instance, if we write int main () and we never say return, I expect the
> function to return 0 (which is what happens when you write return int()).
"main" is special and "int" is not a class.
--
................................................................
: jakob at unthought dot net : And I see the elder races, :
:.........................: putrid forms of man :
: Jakob Østergaard : See him rise and claim the earth, :
: OZ9ABN : his downfall is at hand. :
:.........................:............{Konkhra}...............: