🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #609

GCC bug concerning volatile

#609
From: mike
Date: Wed, 20 Sep 1989 17:53
39 lines
1302 bytes
The following simple C program shows a bug in gcc version 1.35 code generation :

        volatile
        struct foo {
                char    a, b, c;
        };
        
        tst()
        {
        struct  foo     *foo;
        
                foo = (struct foo *) 1234;
        
                foo->a = foo->c;
                foo->a = foo->c;
                foo->a = foo->c;
        }

The assembly output (68K) is :

        #NO_APP
        gcc_compiled.:
        .text
        	.even
        .globl tst
        tst:
        	link a6,#0
        	movew #1234,a0
        	moveb 1236:w,a0@
        	unlk a6
        	rts

Since the structure is marked as volatile the compiler should not be removing
redundant assignments.  A simple work around that I have been using is to mark
the pointer itself as volatile (eg. volatile struct foo *foo; ).

Mike Schloss
mike@apollo.hp.com
decvax!apollo!mike
Technical Details
Message-ID: <8909201748.AA10157@xuucp.ch.apollo.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!APOLLO.COM!mike

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!APOLLO.COM!mike
From: mike@APOLLO.COM
Newsgroups: gnu.gcc.bug
Subject: GCC bug concerning volatile
Message-ID: <8909201748.AA10157@xuucp.ch.apollo.com>
Date: 20 Sep 89 17:53:52 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 39