micompilation of autoconf stack growth test at -O > 0 on ARM

Bug #1203496 reported by Adam Conrad
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Invalid
Undecided
Unassigned
gcc
Invalid
Medium
gcc-4.7 (Ubuntu)
Invalid
Undecided
Unassigned
gcc-4.8 (Ubuntu)
Invalid
Undecided
Unassigned
librep (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

This autoconf test works on x86, but appears to fail on ARM when built with optimisation. It worked fine with gcc-4.6, and fails with 4.7. Versions here were all from current saucy:

gcc-4.6: 4.6.4-3ubuntu1
gcc-4.7: 4.7.3-6ubuntu1
gcc-4.8: 4.8.1-7ubuntu1

(saucy-kde)adconrad@shiva:~/librep-0.90.2$ gcc-4.6 -o conftest -O2 stack.c
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ ./conftest ; echo $?
0
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ gcc-4.7 -o conftest -O2 stack.c
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ ./conftest ; echo $?
1
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ gcc-4.8 -o conftest -O2 stack.c
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ ./conftest ; echo $?
1
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ gcc-4.8 -o conftest -O1 stack.c
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ ./conftest ; echo $?
1
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ gcc-4.8 -o conftest -O0 stack.c
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ ./conftest ; echo $?
0
(saucy-kde)adconrad@shiva:~/librep-0.90.2$ cat stack.c
#include <stdlib.h>

void inner (char *foo) {
  char bar;
  exit (!(foo >= &bar));
}

void main () {
  char foo;
  inner (&foo);
}

Revision history for this message
In , Doko-v (doko-v) wrote :

seen on arm-linux-gnueabihf, as part of an autoconf test in librep:

$ cat stack.c
#include <stdlib.h>

void inner (char *foo) {
  char bar;
  exit (!(foo >= &bar));
}

void main () {
  char foo;
  inner (&foo);
}

$ gcc-4.6 -o conftest -O2 stack.c && ./conftest ; echo $?
0
$ gcc-4.7 -o conftest -O2 stack.c && ./conftest ; echo $?
1
$ gcc-4.8 -o conftest -O2 stack.c && ./conftest ; echo $?
1
$ gcc-4.8 -o conftest -O0 stack.c && ./conftest ; echo $?
0

Revision history for this message
In , Rguenth (rguenth) wrote :

Well, it's clearly a bogus test - you are comparing addresses of two distinct objects which invokes undefined behavior.

Changed in gcc:
importance: Unknown → Medium
status: Unknown → Invalid
Revision history for this message
In , Andreas Schwab (schwab-linux-m68k) wrote :

Casting to uintptr_t should probably make this work as intented.

Revision history for this message
In , Rguenth (rguenth) wrote :

Well, until the compiler comes along and inlines 'inner'.

This is really a GIGO test.

Matthias Klose (doko)
Changed in gcc-4.8 (Ubuntu):
status: New → Invalid
Changed in gcc-4.7 (Ubuntu):
status: New → Invalid
Changed in gcc-linaro:
status: New → Invalid
Revision history for this message
Mattia Rizzolo (mapreri) wrote :

librep workarounded it in 0.90.2-1.4ubuntu1.

Changed in librep (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.