c++/5395: volatile keyword changes volatile write's into write, then read
tim.ousley@ni.com
tim.ousley@ni.com
Tue Jan 15 14:46:00 GMT 2002
>Number: 5395
>Category: c++
>Synopsis: volatile keyword changes volatile write's into write, then read
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jan 15 14:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Tim Ousley
>Release: gcc 3.0.2
>Organization:
>Environment:
redhat Linux 7.2
>Description:
'volatile' keyword changes a variable write into a write followed by a read. This makes it quite difficult to access hardware registers, which can confuse the hardware when read. For instance, an access to a volatile address produces:
movw $100, 10000
movw 10000, %ax
This only happens when using g++. If I change the filename from vol_bug.cpp to vol_bug.c, the code does not write, then read from a volatile location.
>How-To-Repeat:
gcc3 vol_bug.cpp -Os -S
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="vol_bug.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="vol_bug.ii"
IyA1ICJ2b2xfYnVnLmNwcCIKaW5saW5lIHZvaWQgd3JpdGUxNiggdW5zaWduZWQgaW50IGFkZHJl
c3MsIGNvbnN0IGludCBkYXRhKQp7CiAgIGNoYXIqIGFkZHIgPSAoY2hhciAqKWFkZHJlc3M7CiAg
ICoodm9sYXRpbGUgdW5zaWduZWQgc2hvcnQgKikgKChjaGFyICopKGFkZHIpKSA9IGRhdGE7Cn0K
CmludCBtYWluKCl7CiAgIHdyaXRlMTYoMTAwMDAsMTAwKTsKICAgd3JpdGUxNigxMDAwMCwyMDAp
OwoKICAgcmV0dXJuIDA7Cn0K
More information about the Gcc-prs
mailing list