[Bug c++/24058] New: g++ should warn about virtual methods called in constructors and destructors

2005-09-25 Thread tron dot thomas at verizon dot net
When all warnings are enabled the g++ compiler should warn when a virtual 
method is called in a 
constructor or destructor for the class containing the virtual method.

Steps:

1.  Compile the following using the command:  g++ -g -Wall -ansi -pedantic -c

#include 

class Base
{
public:
Base() { Method(); }

virtual ~Base() {}
protected:
virtual void Method() { std::cout << "Base method.\n"; }
};

class Derived : public Base
{
public:
Derived() { Method(); }

protected:
void Method() { std::cout << "Derived method.\n"; }
};

Results:
The code compiles with no errors or warnings

Expected:
The call to Method in the Derived constructor will call Base::Method, and not 
Derived::Method because 
Derived is not constructed and available for use yet.  The compiler should warn 
about these kinds of 
virtual methods calls in constructors as the program may not yield the kind of 
results the developer is 
expecting.

-- 
   Summary: g++ should warn about virtual methods called in
constructors and destructors
   Product: gcc
   Version: 4.0.1
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org


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


[Bug c++/24488] New: GCC should warn about poorly implemented copy assignment operators

2005-10-22 Thread tron dot thomas at verizon dot net
It would be nice for the C++ compiler to warn users when they implement copy
assignment operator that does not copy all parts of an object.

Build the following (contrived) program at maximum warning level:

class Copy
{
public:
Copy() : m_value(0), m_flag(false) {}
Copy& operator=(const Copy& source)
{
m_value = source.m_value;
return *this;
}

private:
int m_value;
bool m_flag;
};

int main()
{
Copy instance;
Copy another;
another = instance;

return 0;
}

Results:
No warning will results

Expected:
The C++ compiler could warn the user that certain members (i.e. m_flag) are not
copied in the implementation of the copy assignment operator.


-- 
   Summary: GCC should warn about poorly implemented copy assignment
operators
   Product: gcc
   Version: 4.0.0
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P5
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tron dot thomas at verizon dot net


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



[Bug c++/22632] New: GCC won't produce assignment operator warnings

2005-07-23 Thread tron dot thomas at verizon dot net
When building with all warnings enabled, GCC can fail to warn when an 
assignment operator can't be 
generated.

Steps:

Use the compiler arguments:
-g -Wall -ansi -pedantic -c

to compile the following C++ code:
#include 

class SetValue : public std::unary_function
{
public:
SetValue(int& value) : m_value(value) {}
void operator() (int value) { m_value = value; }
private:
int& m_value;
};

Results:
The code will compile with no warnings

Expected:
The compiler is unable to generate an assignment operator, and errors will 
occur if code like the 
following is used:

int value = 42;
SetValue functor(42);

int anotherValue = 13;
SetValue anotherFunctor(anotherValue);
anotherFunctor = functor;

The compiler should warn against such problems.

-- 
   Summary: GCC won't produce assignment operator warnings
   Product: gcc
   Version: 4.0.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org


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


[Bug c++/23510] New: Confusing output for improperly terminated template structures

2005-08-21 Thread tron dot thomas at verizon dot net
;-105u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-104u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-103u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-102u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-101u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-100u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-99u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-98u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-97u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-96u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-95u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-94u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-93u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-92u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-91u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-90u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-89u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-88u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-87u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-86u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-85u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-84u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-83u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-82u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-81u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-80u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-79u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-78u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-77u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-76u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-75u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-74u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-73u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-72u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-71u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-70u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-69u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-68u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-67u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-66u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-65u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-64u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-63u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-62u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-61u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-60u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-59u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-58u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-57u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-56u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-55u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-54u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-53u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-52u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-51u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-50u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-49u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-48u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-47u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-46u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-45u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-44u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-43u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-42u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-41u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-40u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-39u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-38u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-37u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-36u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-35u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-34u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-33u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-32u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-31u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-30u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-29u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-28u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-27u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-26u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-25u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-24u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-23u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-22u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-21u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-20u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-19u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-18u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-17u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-16u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-15u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-14u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-13u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-12u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-11u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-10u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-9u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-8u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-7u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-6u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-5u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-4u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-3u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-2u>’
Factorial.cpp:6:   instantiated from ‘Factorial<-1u>’
Factorial.cpp:6:   instantiated from ‘Factorial<0u>’
Factorial.cpp:6:   instantiated from ‘Factorial<1u>’
Factorial.cpp:6:   instantiated from ‘Factorial<2u>’
Factorial.cpp:6:   instantiated from ‘Factorial<3u>’
Factorial.cpp:6:   instantiated from ‘Factorial<4u>’
Factorial.cpp:6:   instantiated from ‘Factorial<5u>’
Factorial.cpp:20:   instantiated from here

Factorial.cpp:6: error: incomplete type ‘Factorial<-495u>’ used in nested name
specifier

Expected:
This is a large amount of confusing output due to the simple fact that the
template structures are not terminated with semicolons.
Briefer output addressing the fundamental problem would better let a developer
know what is wrong with the code.

-- 
   Summary: Confusing output for improperly terminated template
structures
   Product: gcc
   Version: 4.0.1
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P2
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org


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


[Bug c++/13077] Need a way to disable warnings in code

2003-11-16 Thread tron dot thomas at verizon dot net

--- Additional Comments From tron dot thomas at verizon dot net  2003-11-17 00:10 
---
Subject: Re:  Need a way to disable warnings in code

Thanks pinskia.  I did not know about that.  I'm glad there is a way to 
deal with per module settings.
I still don't know how helpful it is because the warning is actually 
generated in a header file, and knowing all the module that would be 
affected by the header is a little tricky.
I've dealt with the problem by stubbing an extra, unnecessary function 
into class that will eliminate the warning when building with GCC.  This 
will work fine for me.

pinskia at gcc dot gnu dot org wrote:

>--- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 22:43 
>---
>What you said about "Project Builder" is not true, it has not been true for the past 
>year.
>Yes it is hard to find where to put per file flags but you can do it.
>Go to the target settings.
>Click on Sources under "Build Phase".
>Click on the file you want to add the flag.
>Click on the left most part of the field and this will bring up a window where you 
>can put the extra 
>flag.
>
>  
>




-- 


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


[Bug c++/18410] New: GCC does not warn about hidden methods

2004-11-09 Thread tron dot thomas at verizon dot net
GCC will not issue a compiler warning when a virtual inheritted method is 
hidden 
 
Steps: 
 
Use the following code to create a file named HideMethod.cpp 
 
class Parent 
{ 
public: 
virtual ~Parent(){} 
virtual void Method(){} 
}; 
 
class Child : public Parent 
{ 
public: 
virtual void Method(int){} 
}; 
 
Compile the code with the following command. 
g++ -g -Wall -ansi -pedantic -c HideMethod.cpp 
 
Results: 
The code will compile with no warnings. 
 
Expected: 
The method Parent::Method() is hidden by the method Child::Method(int), and 
because the -Wall switch was used the compiler should issue a warning about 
this as it can lead to problems. 
 
Adding this code 
 
class GrandChild : public Child 
{ 
public: 
void Test(){ Method(); } 
}; 
 
to HideMethod.cpp will correctly produce this error: 
 
HideMethod.cpp: In member function `void GrandChild::Test()': 
HideMethod.cpp:17: error: no matching function for call to 
`GrandChild::Method()' 
HideMethod.cpp:11: note: candidates are: virtual void Child::Method(int)

-- 
   Summary: GCC does not warn about hidden methods
   Product: gcc
   Version: 3.4.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tron dot thomas at verizon dot net
CC: gcc-bugs at gcc dot gnu dot org


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


[Bug c++/18410] GCC does not warn about hidden methods

2004-11-09 Thread tron dot thomas at verizon dot net

--- Additional Comments From tron dot thomas at verizon dot net  2004-11-10 
01:56 ---
Subject: Re:  GCC does not warn about hidden methods

I tried a serach before I entered the bug.  I couldn't find any results.

pinskia at gcc dot gnu dot org wrote:

>--- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-09 
>23:21 ---
>Confirmed, I thought I saw this in a different bug.
>
>  
>




-- 


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