[Bug c++/34811] New: Classes without attributes declared as const need initializer.

2008-01-16 Thread olof dot tangrot at telia dot com
The appeded code does not compile without errors:
(Verified on avr-gcc (gcc version 4.2.2)

$ avr-gcc -Wall c++_trial_1.cpp
c++_trial_1.cpp:29: error: uninitialized const 'sM'

Using Visual Studio 2005 Express the same code compiles on the highest
warninglevel without warnings or errors.

#include 

unsigned char PORTB;
unsigned char PORTC;

class port_b
{
protected:
inline void setPB0( void ) { PORTB |= (unsigned char) (1<<0);};
inline void resetPB0( void ) { PORTB &= (unsigned char) ~(1<<0);};
};

class port_c
{
protected:
inline void setPC0( void ) { PORTC |= (unsigned char) (1<<0);};
inline void resetPC0( void ) { PORTC &= (unsigned char) ~(1<<0);};
} ;

class signalManager
: protected port_b,
  protected port_c
{
public:
inline void alarmLedOn( void ) {port_b::resetPB0();};
inline void alarmLedOff( void ) {port_b::setPB0();};
} const sM ;

int main( void )
{
printf("Port B %d\n", PORTB);
((signalManager&)sM).alarmLedOff();
printf("Port B %d\n", PORTB);
((signalManager&) sM).alarmLedOn();
printf("Port B %d\n", PORTB);

return 0;
}


-- 
   Summary: Classes without attributes declared as const need
initializer.
   Product: gcc
   Version: 4.2.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
    AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: olof dot tangrot at telia dot com


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



[Bug c++/34811] Classes without attributes declared as const need initializer.

2008-01-16 Thread olof dot tangrot at telia dot com


--- Comment #2 from olof dot tangrot at telia dot com  2008-01-16 14:16 
---
I know about that. The class don't need a contructor, it does not have anything
that needs to be assigned upon creation. Why should the compiler link in code
that does not do anything? I eats memory. Surely that can be resolved at
compile time.


-- 


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