http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59801
Zhendong Su <su at cs dot ucdavis.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |su at cs dot ucdavis.edu --- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> --- For the given code, it does seem make sense to issue a warning (whether or not "volatile" is used) because this is likely a bug in the code. $ gcc-trunk -Wunused-variable small.c $ clang-trunk -Wunused-variable small.c small.c:1:21: warning: unused variable 'a' [-Wunused-variable] static volatile int a; ^ 1 warning generated. $ cat small.c static volatile int a; int main () { return 0; } ---------------------- This also seems to be a missed optimization opportunity: $ gcc-trunk -O3 -S small.c $ cat small.s .file "small.c" .section .text.unlikely,"ax",@progbits .LCOLDB0: .section .text.startup,"ax",@progbits .LHOTB0: .p2align 4,,15 .globl main .type main, @function main: .LFB0: .cfi_startproc xorl %eax, %eax ret .cfi_endproc .LFE0: .size main, .-main .section .text.unlikely .LCOLDE0: .section .text.startup .LHOTE0: .local a .comm a,4,4 .ident "GCC: (GNU) 4.9.0 20140115 (experimental) [trunk revision 206638]" .section .note.GNU-stack,"",@progbits