This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: returning unconstructed objects - bug or a feature?


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}...............:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]