site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com I'm curious what the motivation is for this particular choice. If you don't know the answer don't respond. To be correct, you MUST write it on 2 lines: { 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 -= 1; *(sp - 2) += *sp; } Are you sure you aren't trying to get us to do your homework? ;-) Cheers, -Steve _______________________________________________ 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... At 12:36 PM -0400 6/30/08, J. Aaron Pendergrass wrote: Of course there's a choice to be made. The compiler has to do something. It chose to do something on powerpc that is completely different from what it chooses to do on other architectures, and on other programs which have very similar undefined usages, and which seemed somewhat unintuitive (in the sense that if I were to define a particular behavior it would not have been the one I observed). Because PPC and Intel have different instruction sets and therefor different optimizers. What the spec is saying by "undefined" is that "if a programmer writes code like this it's a bug" so there's no need for compiler writers to do anything but what's most convenient. This is a very common interview question to test basic literacy in the in the C programming language. If you see someone writing code like this it's a good signal not to trust other they write (and not to hire them). :-) There are still some people who think that reducing the number of lines of C somehow reduces code size. This email sent to site_archiver@lists.apple.com
participants (1)
-
Steve Sisak