delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/09/08:46:38

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: printf bug ???
Date: Fri, 05 Jun 1998 18:44:56 -0700
Organization: Alcyone Systems
Lines: 23
Message-ID: <35789F18.156B3204@alcyone.com>
References: <Pine DOT GSO DOT 3 DOT 96 DOT 980605144528 DOT 10548A-100000 AT bert DOT eecs DOT uic DOT edu> <35784F8A DOT AB5D79CC AT gpu DOT srv DOT ualberta DOT ca>
NNTP-Posting-Host: charmaine.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Blaine Hodge wrote:

> > >     printf("%d %d %d", i, i++, i++);
	...
> Then its VC at fault (gee, imagine that), sounds like its evaluating
> it
> using the Pascal calling method, left to right, and not C/C++, right
> to
> left.

No, neither compiler is wrong.  The result of the above code is
undefined.  That means that it can do anything from printing zeroes
(even though i started with 0) to computing pi, to crashing -- any of
those would be perfectly ANSI compliant implementations, since it's a
user error.

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm:+37.20.07/-121.53.38
                                     \
           She glanced at her watch / . . . It was 9:23.
                                   / James Clavell

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019