This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17004] getting warning multiple times


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]