public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function
@ 2005-04-09 12:28 moritz at bunkus dot org
  2005-04-09 12:29 ` [Bug c++/20916] " moritz at bunkus dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 12:28 UTC (permalink / raw)
  To: gcc-bugs

I'll attach a short sample file that works nicely on 32 bit architectures but 
breaks on AMD64. A function taking varargs calls va_start and passes that 
va_list object to another function. This one will output it twice with vprintf. 
Between the two calls to vprintf there's another function call. The second call 
to vprint produces wrong output, e.g.

::mxmsg(1) string honk int 42 string cow!
::mxmsg(2) string  int 1697834872 string 

The same code produces correct output on 32bit platforms.

-- 
           Summary: va_list passed to a function gets messed up by a call to
                    another function
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: moritz at bunkus dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: x86_64-redhat-linux


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
@ 2005-04-09 12:29 ` moritz at bunkus dot org
  2005-04-09 12:30 ` moritz at bunkus dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 12:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From moritz at bunkus dot org  2005-04-09 12:29 -------
Created an attachment (id=8568)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8568&action=view)
source code for the sample case


-- 


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
  2005-04-09 12:29 ` [Bug c++/20916] " moritz at bunkus dot org
@ 2005-04-09 12:30 ` moritz at bunkus dot org
  2005-04-09 12:31 ` moritz at bunkus dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 12:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From moritz at bunkus dot org  2005-04-09 12:30 -------
Created an attachment (id=8569)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8569&action=view)
preprocessed file


-- 


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
                   ` (2 preceding siblings ...)
  2005-04-09 12:31 ` moritz at bunkus dot org
@ 2005-04-09 12:31 ` moritz at bunkus dot org
  2005-04-09 14:11 ` schwab at suse dot de
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 12:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From moritz at bunkus dot org  2005-04-09 12:31 -------
Forgot to mention: compilation was done with a simple "g++ -Wall -o 
va_list_messed_up va_list_messed_up.cpp"

-- 


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
  2005-04-09 12:29 ` [Bug c++/20916] " moritz at bunkus dot org
  2005-04-09 12:30 ` moritz at bunkus dot org
@ 2005-04-09 12:31 ` moritz at bunkus dot org
  2005-04-09 12:31 ` moritz at bunkus dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 12:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From moritz at bunkus dot org  2005-04-09 12:30 -------
Created an attachment (id=8570)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8570&action=view)
output of "g++ -v" on that platform


-- 


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
                   ` (3 preceding siblings ...)
  2005-04-09 12:31 ` moritz at bunkus dot org
@ 2005-04-09 14:11 ` schwab at suse dot de
  2005-04-09 14:14 ` pinskia at gcc dot gnu dot org
  2005-04-09 16:26 ` moritz at bunkus dot org
  6 siblings, 0 replies; 8+ messages in thread
From: schwab at suse dot de @ 2005-04-09 14:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2005-04-09 14:11 -------
You cannot use a va_list any more after passing it to a consumer like vprintf. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
                   ` (4 preceding siblings ...)
  2005-04-09 14:11 ` schwab at suse dot de
@ 2005-04-09 14:14 ` pinskia at gcc dot gnu dot org
  2005-04-09 16:26 ` moritz at bunkus dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-09 14:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-09 14:14 -------
(In reply to comment #5)
> You cannot use a va_list any more after passing it to a consumer like vprintf. 

Just a note to fix your code, use va_copy.


-- 


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


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

* [Bug c++/20916] va_list passed to a function gets messed up by a call to another function
  2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
                   ` (5 preceding siblings ...)
  2005-04-09 14:14 ` pinskia at gcc dot gnu dot org
@ 2005-04-09 16:26 ` moritz at bunkus dot org
  6 siblings, 0 replies; 8+ messages in thread
From: moritz at bunkus dot org @ 2005-04-09 16:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From moritz at bunkus dot org  2005-04-09 16:25 -------
Ups! Thanks for the quick help and sorry for not reading the man page thoroughly 
enough before posting this.

-- 


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


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

end of thread, other threads:[~2005-04-09 16:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-09 12:28 [Bug c++/20916] New: va_list passed to a function gets messed up by a call to another function moritz at bunkus dot org
2005-04-09 12:29 ` [Bug c++/20916] " moritz at bunkus dot org
2005-04-09 12:30 ` moritz at bunkus dot org
2005-04-09 12:31 ` moritz at bunkus dot org
2005-04-09 12:31 ` moritz at bunkus dot org
2005-04-09 14:11 ` schwab at suse dot de
2005-04-09 14:14 ` pinskia at gcc dot gnu dot org
2005-04-09 16:26 ` moritz at bunkus dot org

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).