public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9740: Object included in another is not initialized properly
@ 2003-02-19  2:42 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-02-19  2:42 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, tron

Synopsis: Object included in another is not initialized properly

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Feb 19 02:42:58 2003
State-Changed-Why:
    Reading a good book about C++ might help.
    
    What you do here
    class A {
      int i;
      int p;
    public:
    ==>  A() {A(0); };
      A(int j) {i=j; p=0; cout << "in A constuctor:\np=" << p << endl;};
      int getp() { return p; };
    };
    
    is not redirecting from one constructor to another, but
    you create an unnamed, temporary object and call its
    conversion constructor. The object you're presently in
    in the first constructor is not change, and is left
    uninitialized.
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9740


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/9740: Object included in another is not initialized properly
@ 2003-02-18 11:06 tron
  0 siblings, 0 replies; 2+ messages in thread
From: tron @ 2003-02-18 11:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9740
>Category:       c++
>Synopsis:       Object included in another is not initialized properly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 18 11:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Eviatar Tron
>Release:        3.2.2
>Organization:
>Environment:
Configured with: ./configure
Thread model: posix
>Description:
I have an object a of class A which has a memeber from another class B.

the A constructor includes a statment to zero it's memebrs
when the B constructor is called, it trashes the a object,
so that those members are not zero, but some random value.


>How-To-Repeat:
compile the file using g++ -g 
when run, it prints the value of a.p at the
construction, and after the construction
>Fix:
I tried working with pointers as well, but didnt succeed

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtLmg+CgpjbGFzcyBBIHsKICBpbnQgaTsKICBpbnQgcDsKcHVibGlj
OgogIEEoKSB7QSgwKTsgfTsKICBBKGludCBqKSB7aT1qOyBwPTA7IGNvdXQgPDwgImluIEEgY29u
c3R1Y3RvcjpcbnA9IiA8PCBwIDw8IGVuZGw7fTsKICBpbnQgZ2V0cCgpIHsgcmV0dXJuIHA7IH07
Cn07CgpjbGFzcyBCIHsKCiAgaW50IHgseSx6OwogIEEgYTsKcHVibGljOgogIEIoKSB7IHg9MTsg
eT0yOyB6PTM7IH0KICBCKGludCBwLGludCBxLCBpbnQgdCkgeyB4PXA7IHk9cTsgej10OyB9Owog
IGludCBydW4oKSB7IGNvdXQgPDwgImFmdGVyIGNyZWF0aW9uOlxucD0iIDw8IGEuZ2V0cCgpIDw8
ZW5kbDt9OyAKfTsKICAKCm1haW4oKQp7CiAgQiBiMTsKICBiMS5ydW4oKTsKICAgIAp9Cg==


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-19  2:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-19  2:42 c++/9740: Object included in another is not initialized properly bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18 11:06 tron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).