The following code shows the error... #include <vector> #include <list> #include <map> #include <iostream> #include <string>
using namespace std; class foo { public: vector <string> bar (vector<string> s) { //nothing returned but g++ never complains } }; int main() { string strs[] = {"a", "b"}; foo f; f.bar(vector<string>(strs, strs + 2)); } ------------------------------ [EMAIL PROTECTED]:~/working/TC$ g++ -o g_bug g_bug.cpp [EMAIL PROTECTED]:~/working/TC$ ./g_bug Segmentation fault ------------------------------ #include <vector> #include <list> #include <map> #include <iostream> #include <string> using namespace std; class foo { public: vector <string> bar (vector<string> s) { return vector<string>(); // fixes problem!? } }; int main() { string strs[] = {"a", "b"}; foo f; f.bar(vector<string>(strs, strs + 2)); } ----------------------------- [EMAIL PROTECTED]:~/working/TC$ g++ -o g_bug g_bug.cpp [EMAIL PROTECTED]:~/working/TC$ ./g_bug ----------------------------- Note that with -Wall it warn, but will not report any error... --------------------------------- [EMAIL PROTECTED]:~/working/TC$ g++ -Wall -o g_bug g_bug.cpp g_bug.cpp: In member function std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > foo::bar(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >): g_bug.cpp:12: warning: no return statement in function returning non-void g_bug.cpp:12: warning: control reaches end of non-void function -------------------------------------------- I am using Ubuntu dapper with their version of gcc which I would assume to be pretty up to date. Sorry if this is a repeat, I didn't quite know how to search for this particular bug since it occurs at run time. -- Summary: Seg fault on member function that does not return a val Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: CyrusOmega at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32832