2009/7/20 Gonzalo Tornaria <torna...@math.utexas.edu> > > Really funny... What would you expect the following program to output? > > #include <stdio.h> > #include <string.h> > > int main (void) > { > int i = 1 , j = -1; > char c = 1, d = 1; > > memset(&c, 2, i + j); > memset(&d, 2, i + j); > > printf("%d %d\n", c, d); > > return 0; > } > > On the T2 with gcc (tried a few different versions) it outputs "1 2". > Dunno how to run the sun compiler. > > The asm looks reasonable; excerpt: > > mov 1, %g1 > st %g1, [%fp-8] > mov -1, %g1 > st %g1, [%fp-4] > mov 1, %g1 > stb %g1, [%fp-9] > mov 1, %g1 > stb %g1, [%fp-10] > > ld [%fp-8], %g2 > ld [%fp-4], %g1 > add %g2, %g1, %g1 > add %fp, -9, %g2 > mov %g2, %o0 > mov 2, %o1 > mov %g1, %o2 > call memset, 0 > nop > > ld [%fp-8], %g2 > ld [%fp-4], %g1 > add %g2, %g1, %g1 > add %fp, -10, %g2 > mov %g2, %o0 > mov 2, %o1 > mov %g1, %o2 > call memset, 0 > nop > > Notation: > > i -> [%fp-8] > j -> [%fp-4] > c -> [%fp-9] > d -> [%fp-10] > > > Maybe you can try compiling to assembler on the T2 and compiling this > assembler on your blade to see if it gives some clue? > > Gonzalo > I would have expected 1 1, as you have twice tried to modify zero bytes (i+j=0) That's what I get on my Blade 2000. But on 't2' I get 1 2.
Sticking another printf I get 1 1 after the first memset call, then 1 2 after the second memset call. How to I force gcc to output the assember like this? Since t2 is on a maintence contract, I will call Sun today and log a bug report. I'll do that in the evening here as the phone call will be cheaper - I need to phone from the UK to the USA. Dave --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---