This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange RTL problem

I'm having a really wierd problem with a backend that I'm working on for
the following C code snippet:

int printf(const char *, ...);
int main() {
  signed char c0  = -1;
  unsigned char c1 = 255;
  printf("bs0  = %d %d\n", c0, c1);
  return 0;

I'd like to see output of -1, 255, but my target is generating "255 255".

Looking at the RTL, I see these two INSNs:

(insn 23 21 25 (set (mem/f:QI (plus:PDI (reg/f:PDI 14 %sp)
                (const_int 8 [0x8])) 0)
        (const_int -1 [0xffffffff])) 9 {*movqi} (nil)

(insn 25 23 26 (set (mem/f:QI (plus:PDI (reg/f:PDI 14 %sp)
                (const_int 12 [0xc])) 0)
        (const_int 255 [0xff])) 9 {*movqi} (nil)

which are immediately before the printf call.  Since both arguments are 8
bit quantities, they are stored onto the stack as QI mode, but doing
so they lose the integral promotion that would make them signed or
unsigned (this only happens with vararg functions).

This is really strange... does anyone have any idea what could be going
wrong here?  How are integral promotions different for vararg functions
than they are for other function calls?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]