This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/17336] New: AVRGCC ignores "volatile" keyword for "register" variables


AVRGCC 3.3.2 (20040404)

BUG:

 AVRGCC ignores "volatile" keyword for "register" variables
 when -o2 or -o3 optimization option is used.

Code:
==================================================
register volatile unsigned char flags asm("r16");
int main(void)
{
	while(1)
	{
        	if ( flags & 0x02 )	// Some event detected
        	{
        		flags &= (0xFF-0x02);	// Clear flag
        	}
	}
	return 0;
}
==================================================
Compiler generates:
==================================================
	while(1)
  64:	80 2f       	mov	r24, r16
  66:	99 27       	eor	r25, r25
	{
        	if ( flags & 0x02 )	// Some event detected
  68:	81 ff       	sbrs	r24, 1
  6a:	fe cf       	rjmp	.-4      	; 0x68
        	{
        		flags &= (0xFF-0x02);	// Clear flag
  6c:	80 2f       	mov	r24, r16
  6e:	8d 7f       	andi	r24, 0xFD	; 253
  70:	08 2f       	mov	r16, r24
  72:	99 27       	eor	r25, r25
  74:	f9 cf       	rjmp	.-14     	; 0x68

-- 
           Summary: AVRGCC ignores "volatile" keyword for "register"
                    variables
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: m_klokov at mail dot ru
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17336


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]