------- Comment #11 from joseph at codesourcery dot com  2006-04-18 11:17 
-------
Subject: Re:  function result is dereferenced error

On Tue, 18 Apr 2006, falk at debian dot org wrote:

> Uhm, this has nothing to do at all with evaluation order. Evaluation
> order of arguments is unspecified (not undefined, which wouldn't make a
> lot of sense), but that is in fact irrelevant here, it could lead to,
> say, 3 1 2, but not 1 1 1.
> 
> The actual problem is that val is modified more than once without an 
> intervening sequence point, which makes the behavior undefined.

No, this testcase is unspecified, not undefined.  There are intervening 
sequence points at the start and end of each call to function, and 
function calls do not overlap (DR#087); each call to func suspends the 
execution of main until func returns.  However, the evaluation of the 
arguments to printf may overlap and the order is unspecified, so there are 
many possible outputs from the program (but "3 2 1" and "3 1 1", for 
example, are not possible).


-- 


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

Reply via email to