Bug 20127 - [4.0 Regression] wrong code for volatile struct members
Summary: [4.0 Regression] wrong code for volatile struct members
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Richard Henderson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2005-02-21 22:13 UTC by Paul Schlie
Modified: 2005-02-25 01:57 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-24 21:59:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Schlie 2005-02-21 22:13:45 UTC
The following code does not treat volatile struct members as volatile,
assuming such declarations are valid; if not would exect a warning:

typedef struct {
  volatile int a;
  volatile int b;
  } s;

int main (void){

  s x = {0, 1};
  s y = {2, 3};
  
  x = y;
  y = x;
  
  return x.a + y.a;

}

generates:

000000c6 <main>:
  volatile int a;
  volatile int b;
  } s;

int main (void){
  c6:	cf ef       	ldi	r28, 0xFF	; 255
  c8:	d0 e1       	ldi	r29, 0x10	; 16
  ca:	de bf       	out	0x3e, r29	; 62
  cc:	cd bf       	out	0x3d, r28	; 61

  s x = {0, 1};
  s y = {2, 3};
  
  x = y;
  y = x;
  
  return x.a + y.a;

}
  ce:	84 e0       	ldi	r24, 0x04	; 4
  d0:	90 e0       	ldi	r25, 0x00	; 0
  d2:	0c 94 6b 00 	jmp	0xd6 <_exit>
Comment 1 Andrew Pinski 2005-02-21 22:19:24 UTC
Hmm, SRA creates new variables and then goes and makes them renamed which seems wrong.
Comment 2 GCC Commits 2005-02-25 01:56:32 UTC
Subject: Bug 20127

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-02-25 01:56:18

Modified files:
	gcc            : ChangeLog tree-sra.c 

Log message:
	PR tree-opt/20127
	* tree-sra.c (instantiate_element): Copy TREE_THIS_VOLATILE from
	the type.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7589&r2=2.7590
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-sra.c.diff?cvsroot=gcc&r1=2.52&r2=2.53

Comment 3 Richard Henderson 2005-02-25 01:57:44 UTC
Fixed.
Comment 4 Paul Schlie 2005-02-25 02:06:21 UTC
Subject: Re:  [4.0 Regression] wrong code for
 volatile struct members

Additional Comments From rth at gcc dot gnu dot org  2005-02-25 01:57
> -------
> Fixed.
> 
> -- 

Thank you.