Bug 17006 - unused variable warning only shown on existing constructor
Summary: unused variable warning only shown on existing constructor
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-12 16:52 UTC by Oliver Stoeneberg
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Stoeneberg 2004-08-12 16:52:08 UTC
The following code gives this warning:

62 C:\Dev-Cpp\Projects\gcc-test\main.cpp
[Warning] unused variable 'x'

If you uncomment the constructor, the warning does not appear.

class Test
{
    public:        
    //Test() {}
};

int main(int argc, char *argv[])
{
	Test x;
	
  	return 0;
}

Happened on Windows 2000 SP4 with gcc-3.4.1-20040711-1, mingw-
runtime-3.3 and win32api-2.5.
Compiled with "-Wunused".
Comment 1 Wolfgang Bangerth 2004-08-12 17:35:15 UTC
That's documented behavior: the warning about unused variables is 
only shown if the compiler can know that running con- and destructors 
has no side-effects. 
 
W.