|
![](/i/fill.gif) |
On 17/04/2012 03:03 PM, Warp wrote:
> Invisible<voi### [at] dev null> 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
|
![](/i/fill.gif) |