POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Teach yourself C++ in 21 strange malfunctions Server Time
29 Jul 2024 12:29:53 EDT (-0400)
  Re: Teach yourself C++ in 21 strange malfunctions  
From: Invisible
Date: 17 Apr 2012 10:09:13
Message: <4f8d7989$1@news.povray.org>
On 17/04/2012 03:03 PM, Warp wrote:
> Invisible<voi### [at] devnull>  wrote:
>> When I looked at my function, I found I'd written "it->second;" rather
>> than "return it->second;". Not only is this apparently legal, it doesn't
>> even generate a compile-time /warning/.
>
>    What compiler would that be?
>
>      int test()
>      {
>      }
>
> test.cc:3:13: warning: no return statement in function returning non-void

#include <iostream>
#include <string>

std::string test()
{
}

int main()
{
   std::cout << test();
   return 0;
}

orphi@linux-z30b:~/Work/Logic-01> make Test
g++     Test.cpp   -o Test
orphi@linux-z30b:~/Work/Logic-01> ./Test
Segmentation fault
orphi@linux-z30b:~/Work/Logic-01> g++ --version
g++ (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.