public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17004] New: getting warning multiple times
@ 2004-08-12 16:01 oliverst at online dot de
  2004-08-12 16:03 ` [Bug c++/17004] " oliverst at online dot de
  2004-08-13  0:13 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: oliverst at online dot de @ 2004-08-12 16:01 UTC (permalink / raw)
  To: gcc-bugs

If I compile this code with "-Wunreachable-code" I get
the warning

C:\Dev-Cpp\Projects\gcc-test\main.cpp
In constructor `CTest::CTest()':
19 C:\Dev-Cpp\Projects\gcc-test\main.cpp
[Warning] will never be executed

twice. If I put the constructor code inline in the class
definition I only get it once.

Happened on Windows 2000 SP4 with gcc-3.4.1-20040711-1, mingw-
runtime-3.3 and win32api-2.5.

I already reported it to the MinGW team
(http://sourceforge.net/tracker/index.php?func=detail&aid=992979&group_id=2435&atid=102435),
but I got no response yet. It was just assigned to dannysmith. Because I got no
Linux to check it for the same problem and because I got no responses, I thought
I might report it directly into GCC bugzilla.

#include <iostream>
#include <stdlib.h>

using namespace std;

class CTest
{
public:
CTest();
~CTest() {}
private:
int _impl;
};

CTest::CTest()
{
try {
_impl = 0;
}catch(...){
}
}

int main(int argc, char *argv[])
{
CTest test;

return 0;
}

-- 
           Summary: getting warning multiple times
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oliverst at online dot de
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17004


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/17004] getting warning multiple times
  2004-08-12 16:01 [Bug c++/17004] New: getting warning multiple times oliverst at online dot de
@ 2004-08-12 16:03 ` oliverst at online dot de
  2004-08-13  0:13 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: oliverst at online dot de @ 2004-08-12 16:03 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/17004] getting warning multiple times
  2004-08-12 16:01 [Bug c++/17004] New: getting warning multiple times oliverst at online dot de
  2004-08-12 16:03 ` [Bug c++/17004] " oliverst at online dot de
@ 2004-08-13  0:13 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-13  0:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-13 00:13 -------
Not a bug, as we emit two constructors and this is warning for those two places.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17004


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-13  0:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-12 16:01 [Bug c++/17004] New: getting warning multiple times oliverst at online dot de
2004-08-12 16:03 ` [Bug c++/17004] " oliverst at online dot de
2004-08-13  0:13 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).