Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 11438
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 10877
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Stanislav S. Anokhin <stas@fromru.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 11438 depends on: Show dependency tree
Show dependency graph
Bug 11438 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2003-07-04 22:58
gcc version 3.3 release.
If compile following source with #gcc -o ptest -O3 -fPIC test.c
get Segmentation fault.
If remove static from PTEST declaration all is fine. Compiling with 
#gcc -o ptest -O2 -fPIC test.c produce normal result.

[--cut--]
#include <stdio.h>
#include <stdlib.h>

typedef struct _test
 {
   int p1;
   int p2;
   char *p3;
 } tests;


static tests *PTEST = NULL;
/* tests *PTEST = NULL; */


void init()
 {
  tests *ptest;

   ptest = PTEST;
   ptest = (tests*) malloc(sizeof(tests));
   ptest->p1 = 1;
   PTEST = ptest;
 }


int p2()
 {
  tests *ptest;

   ptest = PTEST;
   return(ptest->p1);
 }

main()
 {
   init();
   printf("p1:%d\n", p2());
 }
[--cut--]

------- Comment #1 From Andrew Pinski 2003-07-04 23:11 -------
This is a binutils bug (we will be documenting what version of `as' gcc
requires, we already have a 
bug filed for that; bug 10877). Closing as dup of bug 10877.
The binutils bug is fixed in binutils 2.13.1, please update binutils and this
will fix your seg fault.

*** This bug has been marked as a duplicate of 10877 ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug