public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/2904: printf changes order
@ 2001-05-22 13:56 guedem
  0 siblings, 0 replies; 3+ messages in thread
From: guedem @ 2001-05-22 13:56 UTC (permalink / raw)
  To: gcc-gnats

>Number:         2904
>Category:       c
>Synopsis:       printf changes order
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 22 13:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     guedem@uni-freiburg.de
>Release:        unknown-1.0
>Organization:
>Environment:
gcc version 2.95.2 19991024 (release)
i486-suse-linux
>Description:
don't know whether this is realy a bug, but printf (and fprint and fvprintf)
seems to change the order of the ouput. The following little 
programm produces the out put "3, 2, 1". But I've expected to 
receive "1, 2, 3".
>How-To-Repeat:
#include <stdio.h>

int main()
{
	int a[] = {1, 2, 3};
	int* iPtr = a; 

	printf("%d, %d, %d\n", *iPtr++, *iPtr++, *iPtr++);
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c/2904: printf changes order
@ 2001-05-22 22:36 Andreas Jaeger
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Jaeger @ 2001-05-22 22:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/2904; it has been noted by GNATS.

From: Andreas Jaeger <aj@suse.de>
To: guedem@uni-freiburg.de
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/2904: printf changes order
Date: 23 May 2001 07:34:51 +0200

 guedem@uni-freiburg.de writes:
 
 > don't know whether this is realy a bug, but printf (and fprint and fvprintf)
 > seems to change the order of the ouput. The following little 
 > programm produces the out put "3, 2, 1". But I've expected to 
 > receive "1, 2, 3".
 > >How-To-Repeat:
 > #include <stdio.h>
 > 
 > int main()
 > {
 > 	int a[] = {1, 2, 3};
 > 	int* iPtr = a; 
 > 
 > 	printf("%d, %d, %d\n", *iPtr++, *iPtr++, *iPtr++);
 > }
 
 The printf output is undefined by ISO C, there's no sequence point
 between the arguments.  It could even be 2,3,1 or something totally
 different.
 
 Andreas
 -- 
  Andreas Jaeger
   SuSE Labs aj@suse.de
    private aj@arthur.inka.de
     http://www.suse.de/~aj


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

* Re: c/2904: printf changes order
@ 2001-05-22 16:16 Phil Edwards
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Edwards @ 2001-05-22 16:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/2904; it has been noted by GNATS.

From: Phil Edwards <pedwards@disaster.jaj.com>
To: guedem@uni-freiburg.de
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/2904: printf changes order
Date: Tue, 22 May 2001 17:56:43 -0400

 On Tue, May 22, 2001 at 08:51:36PM -0000, guedem@uni-freiburg.de wrote:
 > 	printf("%d, %d, %d\n", *iPtr++, *iPtr++, *iPtr++);
 
 You are changing a variable more than once within the same statement.  The
 result is undefined behavior.  Not a compiler bug.
 
 -- 
 pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
 devphil at several other less interesting addresses in various dot domains
 The gods do not protect fools.  Fools are protected by more capable fools.


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

end of thread, other threads:[~2001-05-22 22:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-22 13:56 c/2904: printf changes order guedem
2001-05-22 16:16 Phil Edwards
2001-05-22 22:36 Andreas Jaeger

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