[Bug c++/58325] New: Spurious unused-but-set-variable warning on delete[] of volatile pointer
cyp561 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 5 16:29:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58325
Bug ID: 58325
Summary: Spurious unused-but-set-variable warning on delete[]
of volatile pointer
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cyp561 at gmail dot com
The following code should not generate “volatile.cpp:3:16: warning: variable
‘usedAndSet’ set but not used [-Wunused-but-set-variable]”, but does anyway:
{{{
int main()
{
int *volatile setAndUsed = new int[1];
delete[] setAndUsed;
}
}}}
The generated code looks correct, I assume _ZdaPv is the delete[]:
{{{
.file "volatile.cpp"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
movl $4, %edi
call _Znam
movq %rax, 8(%rsp)
movq 8(%rsp), %rdi
testq %rdi, %rdi
je .L2
call _ZdaPv
.L2:
xorl %eax, %eax
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Gentoo 4.6.4 p1.0, pie-0.5.2) 4.6.4"
.section .note.GNU-stack,"",@progbits
}}}
Changing “delete[]” to “delete” or removing “volatile” removes the warning.
Adding “(void)setAndUsed;” squelches the warning.
Gives the warning: g++-4.6.4 g++-4.7.3
Does not give a warning: g++-3.4.6 g++-4.1.2 g++-4.2.4 g++-4.3.6 g++-4.4.7
g++-4.5.4
More information about the Gcc-bugs
mailing list