gcc-4.2.3 on Hardy/ia32 miscompiles simple code

Bug #256797 reported by John Regehr
22
Affects Status Importance Assigned to Milestone
gcc-4.2 (Ubuntu)
Fix Released
Undecided
Unassigned
Hardy
Fix Released
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;
}

Revision history for this message
Andreas Moog (ampelbein) wrote :

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

Changed in gcc-4.2:
status: New → Confirmed
Revision history for this message
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
Revision history for this message
Colin Watson (cjwatson) wrote :

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

Revision history for this message
Colin Watson (cjwatson) wrote :

See also bug 237134.

Matt Zimmerman (mdz)
Changed in gcc-4.2:
status: Confirmed → Triaged
Matthias Klose (doko)
Changed in gcc-4.2:
status: Triaged → In Progress
Revision history for this message
Matthias Klose (doko) wrote :

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

Revision history for this message
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
Revision history for this message
Cesare Tirabassi (norsetto) wrote :

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

Revision history for this message
eben (erauhut) wrote :

My test cases now pass. Thanks!

Revision history for this message
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  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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