Bug 44682 - [4.6 Regression] warning: variable ‘x’ set but not used
Summary: [4.6 Regression] warning: variable ‘x’ set but not used
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-06-26 13:28 UTC by Wouter Vermaelen
Modified: 2010-06-29 15:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-06-28 00:31:55


Attachments
gcc46-pr44682.patch (604 bytes, patch)
2010-06-28 08:54 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Vermaelen 2010-06-26 13:28:59 UTC
> cat bug.ii
struct Base1 {
    virtual ~Base1() {}
};
struct Base2 {
    virtual ~Base2() {}
};
struct Foo : Base1, Base2 {};

void f(Foo&);

void g(void* v) {
    Base2* base = static_cast<Base2*>(v);
    Foo* foo = static_cast<Foo*>(base);
    f(*foo);
}


> g++ -Wall -c bug.ii
bug.ii: In function ‘void g(void*)’:
bug.ii:12:9: warning: variable ‘base’ set but not used [-Wunused-but-set-variable]


I'm using SVN revision trunk@161411 on linux x86_64.
Comment 1 Andrew Pinski 2010-06-28 00:31:55 UTC
Confirmed.
Comment 2 Jakub Jelinek 2010-06-28 08:54:55 UTC
Created attachment 21021 [details]
gcc46-pr44682.patch

Untested fix.
Comment 3 Jakub Jelinek 2010-06-28 20:13:00 UTC
Subject: Bug 44682

Author: jakub
Date: Mon Jun 28 20:12:31 2010
New Revision: 161511

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161511
Log:
	PR c++/44682
	* class.c (build_base_path): If want_pointer, call mark_rvalue_use
	on expr.

	* g++.dg/warn/Wunused-var-14.C: New test.

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

Comment 4 Jakub Jelinek 2010-06-29 15:24:19 UTC
Fixed.