public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58325] New: Spurious unused-but-set-variable warning on delete[] of volatile pointer
@ 2013-09-05 16:29 cyp561 at gmail dot com
  2013-09-09 10:38 ` [Bug c++/58325] [4.7/4.8/4.9 Regression] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: cyp561 at gmail dot com @ 2013-09-05 16:29 UTC (permalink / raw)
  To: gcc-bugs

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
>From gcc-bugs-return-429045-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Sep 05 16:46:04 2013
Return-Path: <gcc-bugs-return-429045-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20668 invoked by alias); 5 Sep 2013 16:46:04 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20631 invoked by uid 48); 5 Sep 2013 16:46:01 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58325] Spurious unused-but-set-variable warning on delete[] of volatile pointer
Date: Thu, 05 Sep 2013 16:46:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed
Message-ID: <bug-58325-4-Y4A5KdXyyr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58325-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58325-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-09/txt/msg00285.txt.bz2
Content-length: 480

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX325

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-09-05
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-07 16:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-05 16:29 [Bug c++/58325] New: Spurious unused-but-set-variable warning on delete[] of volatile pointer cyp561 at gmail dot com
2013-09-09 10:38 ` [Bug c++/58325] [4.7/4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-09-09 10:39 ` jakub at gcc dot gnu.org
2013-09-09 17:12 ` jakub at gcc dot gnu.org
2013-09-09 17:12 ` jakub at gcc dot gnu.org
2013-09-09 17:14 ` [Bug c++/58325] [4.7 " jakub at gcc dot gnu.org
2014-05-07 16:04 ` jakub at gcc dot gnu.org
2014-05-07 16:19 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).