Your message dated 08 Aug 2003 16:44:51 +0200
with message-id <[EMAIL PROTECTED]>
and subject line Bug#204580: g++: unexpected output using variadic functions in 
classes
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 8 Aug 2003 10:50:15 +0000
>From [EMAIL PROTECTED] Fri Aug 08 05:50:09 2003
Return-path: <[EMAIL PROTECTED]>
Received: from suffix.rc.rug.nl [129.125.3.162] 
        by master.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 19l4oy-0007QT-00; Fri, 08 Aug 2003 05:50:08 -0500
Received: from suffix.rc.rug.nl (remote.client [127.0.0.1])
        by suffix.rc.rug.nl (8.12.9/8.12.9/Debian-3) with ESMTP id 
h78Ao6ua021081
        (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
        Fri, 8 Aug 2003 12:50:06 +0200
Received: (from [EMAIL PROTECTED])
        by suffix.rc.rug.nl (8.12.9/8.12.9/Debian-3) id h78Ao69u021080;
        Fri, 8 Aug 2003 12:50:06 +0200
Message-Id: <[EMAIL PROTECTED]>
From: "Frank B. Brokken" <[EMAIL PROTECTED]>
To: Debian Bug Tracking System <[EMAIL PROTECTED]>
Subject: g++: unexpected output using variadic functions in classes
X-Mailer: reportbug 1.50
Date: Fri, 08 Aug 2003 12:50:06 +0200
Delivered-To: [EMAIL PROTECTED]
X-Spam-Status: No, hits=-6.0 required=4.0
        tests=BAYES_30,HAS_PACKAGE
        version=2.53-bugs.debian.org_2003_07_20
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_07_20 
(1.174.2.15-2003-03-30-exp)

Package: g++
Version: 3:3.3-2
Severity: normal



-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux suffix 2.4.21 #1 Fri Aug 1 13:53:33 CEST 2003 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages g++ depends on:
ii  cpp                           3:3.3-2    The GNU C preprocessor.
ii  g++-3.3                       1:3.3.1-1  The GNU C++ compiler
ii  gcc-3.3                       1:3.3.1-1  The GNU C compiler


Hi,
    The following little program produces unexpected output. As an
alternate compiler (as a check I used the Intel C++ compiler version 7.0) did
not produce the problem, I assume I ran into a little bug; hence the
bugreport. The problem is described in some detail beyond the program's
source: 

=====================================================================
#include <iostream>
#include <cstdarg>

using namespace std;

class Foo
{
    va_list list;

    public:
        Foo(int n, ...)
        {   
            va_start(list, n);
        }
        void bar() const
        {
            va_list l(list);
            cout << "Saw " << va_arg(l, int) << endl;
        }
};

void two(int start, Foo foo)
{
    for (int idx = 0; idx < 2; idx++)
        foo.bar();
}

void three(int start, int end, Foo foo)
{
    for (int idx = 0; idx < 2; idx++)
        foo.bar();
}

int main(int argc, char **argv)
{
    Foo foo(3, 15);

    two(2, foo);
    three(2, 2, foo);      // unexpected output from here.
    two(2, foo);

    return 0;
}
==================================================================

Problem description:

The clas `Foo' has a constructor accepting variable numbers of arguments. It
initializes a `va_list' data member which is used to initialize a local
`va_list' variable inside its `bar()' function. The `bar()' function then
prints the first of the variable arguments, which is, in this program, always
an `int' value.

The function `two()' receives two value-type arguments: an `int' and a `Foo'
object: the `Foo' object is therefore copied internally to initialize the
parameter `foo'. The `int' argument is not used, and `foo.bar()' is called
twice.

The function `three()' receives three value-type arguments, two `int's and a
`Foo' object. Both `int' arguments are not used, and `foo.bar()' is called
twice, like in the function `two()'.

In `main()' a `Foo' object is constructed, receiving 2 arguments. The second
value, 15, is the `int' to be accessed by `Foo::bar()'.

At the first call of `two()', 15 is displayed, as expected. Then, unexpected
values are displayed by the call of `three()'. Therafter, the problem
persists: calling `two()' for the second time now also produces unexpected
values.

On my computer I get the following output:

Saw 15
Saw 15
Saw -1073743160
Saw -1073743160
Saw -1073743160
Saw -1073743160

As mentioned, when the program is compiled by, e.g., the Intel V 7.0 compiler 
the problem does not appear. In that case, all displayed values are 15, as
expected. 

Hopefully the problem can be solved. If I can assist, please let me know.

Kind regards,

Frank B. Brokken.


---------------------------------------
Received: (at 204580-done) by bugs.debian.org; 8 Aug 2003 14:44:57 +0000
>From [EMAIL PROTECTED] Fri Aug 08 09:44:56 2003
Return-path: <[EMAIL PROTECTED]>
Received: from mx03.uni-tuebingen.de [134.2.3.13] 
        by master.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 19l8UB-00018u-00; Fri, 08 Aug 2003 09:44:55 -0500
Received: from juist (semeai.Informatik.Uni-Tuebingen.De [134.2.15.66])
        by mx03.uni-tuebingen.de (8.12.3/8.12.3) with ESMTP id h78EipUC021387
        for <[EMAIL PROTECTED]>; Fri, 8 Aug 2003 16:44:54 +0200
Received: from falk by juist with local (Exim 3.36 #1 (Debian))
        id 19l8U7-0002em-00
        for <[EMAIL PROTECTED]>; Fri, 08 Aug 2003 16:44:51 +0200
X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ
 wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2<T^
To: [EMAIL PROTECTED]
Subject: Re: Bug#204580: g++: unexpected output using variadic functions in 
classes
References: <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
From: Falk Hueffner <[EMAIL PROTECTED]>
Date: 08 Aug 2003 16:44:51 +0200
In-Reply-To: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Lines: 4
User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.5 (cabbage)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-AntiVirus: checked by AntiVir Milter 1.0.4; AVE 6.21.0.0; VDF 6.21.0.6
Delivered-To: [EMAIL PROTECTED]
X-Spam-Status: No, hits=-3.3 required=4.0
        tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_GNUS_UA
        version=2.53-bugs.debian.org_2003_07_20
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_07_20 
(1.174.2.15-2003-03-30-exp)

Submitter says he can't reproduce it with non-invalid code, so closing

-- 
        Falk


Reply via email to