public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39803]  New: Bogus 'unused value' warning on declarations of non-POD arrays
@ 2009-04-17 23:05 lcwu at gcc dot gnu dot org
  2009-04-17 23:07 ` [Bug c++/39803] " lcwu at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lcwu at gcc dot gnu dot org @ 2009-04-17 23:05 UTC (permalink / raw)
  To: gcc-bugs

When compiling the following program using the mainline GCC (4.5) with -Wunused
flag, we get a bogus "unused value" warning on the array declaration:

$ cat Wunused-14.C
#include <utility>

using std::pair;

int foo() {
  pair<int, const char*> components[3];
  components[0].first = 0;
  return 0;
}

$ g++ -Wunused -c Wunused-14.C 
Wunused-14.C: In function 'int foo()':
Wunused-14.C:6: warning: value computed is not used

Here is the version string of the compiler used:
Target: x86_64-unknown-linux-gnu
gcc version 4.5.0 20090414 (experimental) (GCC)


-- 
           Summary: Bogus 'unused value' warning on declarations of non-POD
                    arrays
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lcwu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39803


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

* [Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays
  2009-04-17 23:05 [Bug c++/39803] New: Bogus 'unused value' warning on declarations of non-POD arrays lcwu at gcc dot gnu dot org
@ 2009-04-17 23:07 ` lcwu at gcc dot gnu dot org
  2009-04-20 21:13 ` lcwu at gcc dot gnu dot org
  2009-04-20 21:46 ` lcwu at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: lcwu at gcc dot gnu dot org @ 2009-04-17 23:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from lcwu at gcc dot gnu dot org  2009-04-17 23:07 -------
This bogus warning started to show up after the fix for PR c++/39551 was
submitted (at revision 146132). And the root cause for the issue is that C++
front-end generates the following code to initialize the local 'pair' array:
(see build_vec_init() in cp/init.c)

*(struct pair[3] *) ({
  (D.2247 = (struct pair *) &components);
  (D.2248 = D.2247);
  (D.2249 = 2);
  for_stmt
    {
      D.2249 != -1;
      --D.2249;
      __comp_ctor  (NON_LVALUE_EXPR <D.2248>);
      ++D.2248;
    }
  D.2247; })

The INDIRECT_REF operation (*) in the above code was later determined useless
and therefore deleted. However, since we didn't know that the INDIRECT_REF
expression was actually created by the compiler (instead of coming from the
user code) and therefore mistakenly emit an 'unused value' warning.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39803


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

* [Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays
  2009-04-17 23:05 [Bug c++/39803] New: Bogus 'unused value' warning on declarations of non-POD arrays lcwu at gcc dot gnu dot org
  2009-04-17 23:07 ` [Bug c++/39803] " lcwu at gcc dot gnu dot org
@ 2009-04-20 21:13 ` lcwu at gcc dot gnu dot org
  2009-04-20 21:46 ` lcwu at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: lcwu at gcc dot gnu dot org @ 2009-04-20 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from lcwu at gcc dot gnu dot org  2009-04-20 21:13 -------
Subject: Bug 39803

Author: lcwu
Date: Mon Apr 20 21:13:08 2009
New Revision: 146454

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146454
Log:
        PR c++/39803
        * gcc/cp/init.c (build_vec_init): Set TREE_NO_WARNING on the
        compiler-generated INDIRECT_REF expression.
        * gcc/testsuite/g++.dg/warn/Wunused-14.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wunused-14.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39803


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

* [Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays
  2009-04-17 23:05 [Bug c++/39803] New: Bogus 'unused value' warning on declarations of non-POD arrays lcwu at gcc dot gnu dot org
  2009-04-17 23:07 ` [Bug c++/39803] " lcwu at gcc dot gnu dot org
  2009-04-20 21:13 ` lcwu at gcc dot gnu dot org
@ 2009-04-20 21:46 ` lcwu at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: lcwu at gcc dot gnu dot org @ 2009-04-20 21:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from lcwu at gcc dot gnu dot org  2009-04-20 21:45 -------
The fix for this bug was committed to mainline at revision 146454.


-- 

lcwu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39803


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

end of thread, other threads:[~2009-04-20 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 23:05 [Bug c++/39803] New: Bogus 'unused value' warning on declarations of non-POD arrays lcwu at gcc dot gnu dot org
2009-04-17 23:07 ` [Bug c++/39803] " lcwu at gcc dot gnu dot org
2009-04-20 21:13 ` lcwu at gcc dot gnu dot org
2009-04-20 21:46 ` lcwu at gcc dot gnu dot 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).