This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17004] getting warning multiple times
- From: "oliverst at online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Aug 2004 16:03:14 -0000
- Subject: [Bug c++/17004] getting warning multiple times
- References: <20040812160151.17004.oliverst@online.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From oliverst at online dot de 2004-08-12 16:03 -------
I posted this as an comment at sf.net, but I think it might also make sense to
post it here:
This code gives me the warning 5 times on line 46. The
interetsing thing is, that if you remove the unused var
"mname" you only get it four times.
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
bool test()
{
string result;
string mname;
if( result.empty() )
return false;
char *tmp = NULL; //(char*)malloc(result.length()+1);
char tmpStr[256];
strcpy(tmpStr, result.c_str());
tmp = tmpStr;
char *pos = NULL;
try {
pos = strstr(tmp, ".");
if (pos != NULL) {
*pos = 0;
tmp = pos+1;
pos = strstr(tmp, ".");
if (pos != NULL) {
*pos = 0;
tmp = pos+1;
pos = strstr(tmp, ".");
if (pos != NULL) {
tmp = pos+1;
}
else
return false;
}
else
return false;
}
else
return false;
}
catch(...) {
return false;
}
return true;
}
int main(int argc, char *argv[])
{
bool tmp = test();
system("PAUSE");
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17004