bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lack of return values not reported


From: Kenton Varda
Subject: Re: Lack of return values not reported
Date: Wed, 23 May 2001 12:04:05 GMT
User-agent: KNode/0.4

(Note:  please ignore this if it is a double-post.  I sent a reply several 
hours ago, and it hasn't shown up, so I'm assuming something went wrong and 
am sending it again using a better client.)

Maurizio Loreti wrote:
> This does not happen for me.

It only seems to happen sometimes.  I am not sure what determines it.  
Sorry, I should have included a code sample in the original message.

Here is an example of the problem.  Note that if you un-comment the line 
which is commented out, the program works as expected.  With the line 
commented, though, one would expect GCC to produce a warning or error, but 
it does not.  Instead, the program compiles and promptly segfaults when run.

[~/stf/src/test] cat testreturn.cpp
#include <string>
#include <iostream>
 
string ObjectName2Filename(string moduleName)
{
    int pos;
    while((pos = moduleName.find_first_of(':')) >= 0)
        moduleName.replace(pos, 2, "/");
//  return moduleName;
}
 
int main()
{
    cout << ObjectName2Filename("package::Object") << endl;
    return 0;
}
[~/stf/src/test] g++ -Wall -O2 -o testreturn testreturn.cpp
[~/stf/src/test] ./testreturn
Segmentation fault (core dumped)
[~/stf/src/test]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]