public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44362]  New: Bogus set-but-not-used warning
@ 2010-06-01 12:35 rguenth at gcc dot gnu dot org
  2010-06-01 13:58 ` [Bug c++/44362] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-01 12:35 UTC (permalink / raw)
  To: gcc-bugs

#define WORDS_BIG_ENDIAN 0
int foo(int x, int y)
{
  int a = x;
  int b = y;
  int j = WORDS_BIG_ENDIAN ? a : b;
  return j;
}

which actually breaks bootstrap with C++.


-- 
           Summary: Bogus set-but-not-used warning
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
@ 2010-06-01 13:58 ` jakub at gcc dot gnu dot org
  2010-06-03 18:01 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-01 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2010-06-01 13:58 -------
More complete testcase:
/* { dg-options "-Wunused" } */
/* { dg-do compile } */

int
f1 (int u, int v)
{
  int a, b, c, d, e, f, g, h, i;
  a = u;
  b = v;
  c = u;
  d = v;
  e = u;
  f = v;
  g = u == 6 ? a : b;
  h = 0 ? c : d;
  i = 1 ? e : f;
  return g + h + i;
}

No warnings with C, two warnings with C++, apparently because
build_conditional_expr folds the created COND_EXPR before it has been marked.

Another testcase, again, no set but not used warnings in C but some in C++.
/* { dg-options "-Wunused" } */
/* { dg-do compile } */

void
f1 (int u, int v)
{
  int a, b, c, d, e, f;
  a = u;
  b = v;
  c = u;
  d = v;
  e = u;
  f = v;
  u == 6 ? a : b; /* { dg-warning "no effect" } */
  0 ? c : d; /* { dg-warning "no effect" } */
  1 ? e : f; /* { dg-warning "no effect" } */
}


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
  2010-06-01 13:58 ` [Bug c++/44362] " jakub at gcc dot gnu dot org
@ 2010-06-03 18:01 ` rguenth at gcc dot gnu dot org
  2010-06-04  0:17 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-03 18:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-06-03 18:01 -------
*** Bug 44405 has been marked as a duplicate of this bug. ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amylaar at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
  2010-06-01 13:58 ` [Bug c++/44362] " jakub at gcc dot gnu dot org
  2010-06-03 18:01 ` rguenth at gcc dot gnu dot org
@ 2010-06-04  0:17 ` paolo dot carlini at oracle dot com
  2010-06-04  0:25 ` amylaar at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-04  0:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2010-06-04 00:17 -------
Is this also the same issue? Probably not, but it causes tons of warnings in
the libstdc++ testsuite (with -Wall in CXXFLAGS) and seems bogus to me.

struct ratio
{
  static const int a = 3;
};

const int ratio::a;

int f()
{
  ratio r;
  return r.a;
}


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo dot carlini at oracle
                   |                            |dot com


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-06-04  0:17 ` paolo dot carlini at oracle dot com
@ 2010-06-04  0:25 ` amylaar at gcc dot gnu dot org
  2010-06-04  0:28 ` paolo dot carlini at oracle dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2010-06-04  0:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from amylaar at gcc dot gnu dot org  2010-06-04 00:25 -------
(In reply to comment #3)
> Is this also the same issue? Probably not, but it causes tons of warnings in
> the libstdc++ testsuite (with -Wall in CXXFLAGS) and seems bogus to me.

I don't see any connection (beyond the warning flag); there is no
COND_EXPR in your testcase.


-- 


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-06-04  0:25 ` amylaar at gcc dot gnu dot org
@ 2010-06-04  0:28 ` paolo dot carlini at oracle dot com
  2010-06-04  0:46 ` amylaar at gcc dot gnu dot org
  2010-06-04 18:43 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-04  0:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo dot carlini at oracle dot com  2010-06-04 00:28 -------
Ok, let me open another PR. Would you suggest somebody to add in CC?


-- 


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-06-04  0:28 ` paolo dot carlini at oracle dot com
@ 2010-06-04  0:46 ` amylaar at gcc dot gnu dot org
  2010-06-04 18:43 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2010-06-04  0:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from amylaar at gcc dot gnu dot org  2010-06-04 00:46 -------
(In reply to comment #5)
> Ok, let me open another PR. Would you suggest somebody to add in CC?

Maybe we should have a meta-bug for all the issues with this warning flag.
So that'd be at least this one, PR 44361, and the new bug that you'll file.


-- 


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


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

* [Bug c++/44362] Bogus set-but-not-used warning
  2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-06-04  0:46 ` amylaar at gcc dot gnu dot org
@ 2010-06-04 18:43 ` jakub at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-04 18:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2010-06-04 18:43 -------
Subject: Bug 44362

Author: jakub
Date: Fri Jun  4 18:42:42 2010
New Revision: 160289

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160289
Log:
        PR c++/44362
        * call.c (build_conditional_expr): If both arg2 and arg3 are lvalues
        with the same type, call mark_lvalue_use on both.

        * c-c++-common/Wunused-var-10.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/Wunused-var-10.c
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2010-06-04 18:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-01 12:35 [Bug c++/44362] New: Bogus set-but-not-used warning rguenth at gcc dot gnu dot org
2010-06-01 13:58 ` [Bug c++/44362] " jakub at gcc dot gnu dot org
2010-06-03 18:01 ` rguenth at gcc dot gnu dot org
2010-06-04  0:17 ` paolo dot carlini at oracle dot com
2010-06-04  0:25 ` amylaar at gcc dot gnu dot org
2010-06-04  0:28 ` paolo dot carlini at oracle dot com
2010-06-04  0:46 ` amylaar at gcc dot gnu dot org
2010-06-04 18:43 ` jakub 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).