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]
Other format: [Raw text]

[Bug c++/39045] New: Not inited referense.


g++ allows to exist not inited reference in this case:

struct X
{
   int &x;
};

int main()
{
    X* p_x = new X; // now there is not inited reference (p_x->x)
    // now we can try to use p_x->x
    std::cout << p_x->x << std::endl; // segmentation fault
    return 0;
}

There are no errors or warnings. Compilation is successfull. 

I have tested on g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3).
Also it "works" on g++ 4.3.


-- 
           Summary: Not inited referense.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexey dot veselovsky at gmail dot com


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


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