Bug 23702 - volatile const members of structures not treated as volatile
Summary: volatile const members of structures not treated as volatile
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-02 19:32 UTC by Steven L. Zook
Modified: 2009-08-25 13:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test code (201 bytes, text/plain)
2005-09-02 19:33 UTC, Steven L. Zook
Details
Sample compiled output for test code (318 bytes, text/plain)
2005-09-02 19:36 UTC, Steven L. Zook
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven L. Zook 2005-09-02 19:32:11 UTC
Volatile const members of a struct are not generating a load when read while 
volatile non-const members are loaded (volatile const objects outside of a 
structure do generate a load when read). const members of a volatile struct 
generate two loads when read (strange code being produced in this case). This 
has been seen in 3.3.3 (for x86 and m68k targets) and 3.4.4 (for m68k targets, 
untested on x86). The attached test.cpp file when compiled gcc -c -save-temps 
test.cpp on 3.3.3 under cygwin (x86 target) produces the attached test.s 
output. Multiple stores on volatile const members of structs get optimized 
away as well (this is not demonstrated in the attached test code). Note that 
when the test code is compiled as C rather than C++, correct code gets 
produced.
Comment 1 Steven L. Zook 2005-09-02 19:33:33 UTC
Created attachment 9652 [details]
Test code
Comment 2 Steven L. Zook 2005-09-02 19:36:12 UTC
Created attachment 9653 [details]
Sample compiled output for test code

This sample was compiled:
gcc -c -save-temps test.cpp
on rev 3.3.3 under Cygwin
Comment 3 Steven L. Zook 2005-09-19 20:06:58 UTC
Test using i686-pc-cygwin with revision 4.0.1 shows problem resolved and good 
code being emitted (although two new warnings are output about non-local 
anonymous variables).
Comment 4 Wolfgang Bangerth 2009-08-25 13:59:20 UTC
gcc 3.3 has not been maintained for a long time. Since you say that gcc 4.0
fixes the bug, I think we can close the bug.

W.