site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:references:message-id:from:to :in-reply-to:content-type:x-mailer:mime-version:subject :content-transfer-encoding:date:cc; bh=hpiIk/HZJiJ5bb5gLfoAwsjSc1fGYA85DXqG0rMp7NA=; b=LnVV7lkXxRmsuPiuPD+jTg4hW+tK/WN4CL/CBiDB2/vZP1EWimC/tHppSJKoEUD9G6 X2xS9gDnqicSM1WquGvD8V6lpUDw9/XoSM14ARTmThAG83OGDWzb/2n30qExCHw19j1K 3tT9/gJgtnpIypq3FJgXJ2rKqtL2nzvR5MkPI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:message-id:from:to:in-reply-to:content-type:x-mailer :mime-version:subject:content-transfer-encoding:date:cc; b=nvX7CqUXL2NjmhQ8WAxKH0EjjGZM29LG3bkc3Yov6PGyL9zC0puCdUTwxbR3PElNw4 IRSz5Y7W1b7sWzG8ZQCcCJRtcvYxAs/Ms+WQtz0t3Uu2jqgs09S3151YuhouW8nmFQ97 vYI3Nwv8Sk48VO7SxbTkJtoML+Ba3/HNm/d2c= Sent from my iPhone Here's some sample code that demonstrates the behavior: { long stack[4] = {1,2,3,4}; long *sp = test + 4; /* top of stack is at (sp - 1) */ /* add the top of stack to the next element and pop */ *(sp - 2) += *(--sp); } One might expect this to result in a stack like: {1, 2, 7, 4} {1, 6, 3, 4} But in fact it results in: {1, 7, 3, 4} This just seems bizarre to me. The most bizarre part in my mind is that one might think the program above should be identical to: { long stack[4] = {1,2,3,4} int sp = 4; stack[sp-2] += stack[--sp]; } but this snippet actually results in {1,2,7,4}. Does anyone have insight into this? Thanks, -Aaron _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/pinskia%40gmail.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jun 30, 2008, at 6:21, "J. Aaron Pendergrass" <james.pendergrass@jhuapl.edu
wrote: Hello list,
I just ran into what seems to be fairly peculiar behavior of Apple's GCC (v4.0.1 PPC) that seemed worth pointing out. It is hard to say if it is really a bug since the C spec is fairly non-deterministic, but it is peculiar. This is the behavior of GNU GCC (v 4.2.3 on Ubuntu x86-32) and Apple GCC (v4.0.1) on Intel. Another reasonable guess might be that the prefix- decrement would be evaluated before the lhs is resolved to a value which should result in: Again, I'm not sure that this is really a bug since the C spec is annoyingly vague about exactly when prefix increment/decrement is supposed to happen. But it seems like it should at least be consistent between the two cases. This email sent to pinskia@gmail.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Andrew Pinski