Bug 65399 - Compiler produces wrong output.
Summary: Compiler produces wrong output.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-05-23 05:39 UTC by Kjartan Maraas
Modified: 2007-04-18 16:42 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-12-15 20:35:17 UTC
Embargoed:


Attachments (Terms of Use)
test case for compiler bug (559 bytes, patch)
2002-05-23 07:47 UTC, Kjartan Maraas
no flags Details | Diff

Description Kjartan Maraas 2002-05-23 05:39:11 UTC
Description of Problem:

The attached testcase produces wrong output when compiled with -O2
Version-Release number of selected component (if applicable):

2.96-110
How Reproducible:
Every time

Steps to Reproduce:
1. Compile test.c with -O2
2. run
3. 

Actual Results:
[kmaraas@sevilla kmaraas]$ ./test
should be '/Documents':	/Documents
should be 'Documents':	Documents
should be 'Documents':	/Documents
should be 'Documents':	Documents

Expected Results:
Correct output

Additional Information:
	
Also get the same results with gcc3 (gcc3-3.0.4-1)

Comment 1 Jakub Jelinek 2002-05-23 07:42:04 UTC
No testcase attached...

Comment 2 Kjartan Maraas 2002-05-23 07:47:06 UTC
Created attachment 58266 [details]
test case for compiler bug

Comment 3 Kjartan Maraas 2002-05-23 07:47:29 UTC
Sorry about that :) Should be there now

Comment 4 Kjartan Maraas 2002-05-27 11:51:19 UTC
Any news on this? Would be nice to know if it actually is a bug in the compiler
or not. Sorry to be nagging about it, but I suddenly stopped trusting my
compiler after seeing this :)

Comment 5 Jakub Jelinek 2002-05-27 11:59:21 UTC
I've made a self contained testcase from it (bellow), verified the bug
in 2.96-RH and 3.0.x and found it is works just fine in 3.1.
As it works in 3.1, it is lower priority to me ATM.

typedef struct
{
  char *str;
  int len;
} A;

A *foo (void)
{
  static A x;
  x.str = "1234";
  x.len = 5;
  return &x;
}

int bar (const char *x)
{
}

char *baz (const char *x)
{
  return (char *) x;
}

int
main (int argc, char *argv[])
{
  char *s, *t;
  A *u;

  u = foo ();
  t = (*u->str == '\0') ? u->str : (u->str + 1);
  s = baz ((*u->str == '\0') ? u->str : (u->str + 1));
  bar (s);
  bar (t);
  if (*s != '2')
    abort ();
  return 0;
}

Comment 6 Kjartan Maraas 2002-05-27 12:52:27 UTC
I had someone test it on 3.1 sparc and he saw the problem there too. I'll try to
get the version from him.

Comment 7 Kjartan Maraas 2002-05-27 16:48:34 UTC
He used 3.1.0 from sunfreeware. Self compiled.

Comment 8 Kjartan Maraas 2002-08-24 21:42:36 UTC
Close this as fixed in the latest release?

Comment 9 Alan Cox 2002-12-15 20:35:17 UTC
Confirmed ok in 8.0



Note You need to log in before you can comment on or make changes to this bug.