[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#342126: gcc-4.0: gcc generates bad assembly code for simple code



Package: gcc-4.0
Version: 4.0.2-5
Severity: normal

When I compile the following simple code, gcc fails with:
/tmp/ccySlj9q.s: Assembler messages:
/tmp/ccySlj9q.s:56: Error: missing or invalid immediate expression `' taken as 0
/tmp/ccySlj9q.s:56: Error: suffix or operands invalid for `call'

I've ran gcc -S in the code and I found a "call $" in the compiled code for parse_cmd.

Here is the code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

struct sstate {
 int daemon;
 int run;
 int level;
 struct timespec sleep;
 int sleep_h;
 int max_level;
 int min_level;
 int total_states;
};

typedef struct sstate tstate;
static int parse_cmd(char *argv[], int argc, tstate *state) {
 int i = 1;
 while (i < argc) {
   char *op = argv[i++];
   if (strcmp(op, "-i") == 0) {
     if (i >= argc || sscanf(argv[i++], "%d", $(state->sleep_h)) != 1) {
       return 0;
     }
   } else if (strcmp(op, "-h") == 0) {
     if (i >= argc || sscanf(argv[i++], "%d", &state->max_level) != 1) {
       return 0;
     }
   } else if (strcmp(op, "-l") == 0) {
     if (i >= argc || sscanf(argv[i++], "%d", &state->min_level) != 1) {
       return 0;
     }
   } else if (strcmp(op, "-f") == 0) {
     state->daemon = 0;
   } else {
     return 0;
   }
 }
 return 1;
}

tstate state;

int main(int argc, char *argv[]) {
 if (! parse_cmd(argv, argc, &state)) {
   exit(1);
 }
 return 0;
}



-- System Information:
Debian Release: testing/unstable
 APT prefers unstable
 APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-2-k7
Locale: LANG=pt_BR, LC_CTYPE=pt_BR (charmap=ISO-8859-1)

Versions of packages gcc-4.0 depends on:
ii binutils 2.16.1cvs20051117-1 The GNU assembler, linker and bina
ii  cpp-4.0              4.0.2-5             The GNU C preprocessor
ii gcc-4.0-base 4.0.2-5 The GNU Compiler Collection (base ii libc6 2.3.5-8.1 GNU C Library: Shared libraries an
ii  libgcc1              1:4.0.2-5           GCC support library

Versions of packages gcc-4.0 recommends:
ii libc6-dev 2.3.5-8.1 GNU C Library: Development Librari
pn  libmudflap0-dev               <none>     (no description available)

-- no debconf information




Reply to: