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]

Illegal use of uninitialized reference, improperly allowed


#include <iostream>

struct A
{
  int & a, & b;
  
  A():a(b), b(* new int(1)) {};
};

int main(...)
{
  A a;
  
  cout << & a.a << ", " << & a.b << endl;
}

a.a will be NULL in this case. Shouldn't the compiler notice the
reference to A::b, which is not initialized yet?

Version:
gcc version egcs-2.91.66 Debian GNU/Linux (egcs-1.1.2 release)

Thank you.

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