Ubuntu

gcc-4.2.3 on Hardy/ia32 miscompiles simple code

Reported by John Regehr on 2008-08-11
22
Affects Status Importance Assigned to Milestone
gcc-4.2 (Ubuntu)
Undecided
Unassigned
Hardy
High
Matthias Klose

Bug Description

Binary package hint: gcc-4.2

This is bizarre... gcc-4.2.3 for Hardy on ia32 compiles the code below into a program that prints 1. The correct answer is 0, and this is what all other compilers (including gcc-4.1 and gcc-3.4 on Hardy/ia32) return.

Furthermore, FSF gcc-4.2.3 also gives the correct answer!

Probably someone should look into this as comparison errors like this could easily have security implications.

#include <stdio.h>

int func_1 (void)
{
  signed char l_11 = 1;
  unsigned char l_12 = -1;
  return (l_11 > l_12);
}

int main (void)
{
  printf ("%d\n", func_1());
  return 0;
}

Andreas Moog (amoog) wrote :

I can confirm this with
gcc:
  Installed: 4:4.2.3-1ubuntu6

Changed in gcc-4.2:
status: New → Confirmed
Colin Watson (cjwatson) wrote :

Confirmed with gcc-4.2 4.2.3-2ubuntu7 in Hardy. However, 4.2.4-3ubuntu2 in Intrepid does *not* exhibit this bug.

Changed in gcc-4.2:
assignee: nobody → doko
importance: Undecided → High
status: New → Confirmed
status: Confirmed → Fix Released
Colin Watson (cjwatson) wrote :

I've further confirmed that 4.2.3-4ubuntu1 (an older version in Intrepid) did not exhibit this bug.

Colin Watson (cjwatson) wrote :

See also bug 237134.

Matt Zimmerman (mdz) on 2008-09-02
Changed in gcc-4.2:
status: Confirmed → Triaged
Matthias Klose (doko) on 2008-09-03
Changed in gcc-4.2:
status: Triaged → In Progress
Matthias Klose (doko) wrote :

test packages are now available in the ubuntu-toolchain PPA.
see https://launchpad.net/~ubuntu-toolchain/+archive

Martin Pitt (pitti) wrote :

Accepted into -proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in gcc-4.2:
status: In Progress → Fix Committed
Cesare Tirabassi (norsetto) wrote :

Works for me. I also tested all my sources with it and didn't notice any regression.

eben (erauhut) wrote :

My test cases now pass. Thanks!

Steve Beattie (sbeattie) wrote :

gcc-4.2 4.2.4-1ubuntu3, which included a fix to address this issue, was released to hardy-updates on 2008-10-22. Closing this bug.

Changed in gcc-4.2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers