Bug 41110 - [4.5 regression] Wrong "unused variable" warning
Summary: [4.5 regression] Wrong "unused variable" warning
Status: RESOLVED DUPLICATE of bug 41109
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-08-18 18:56 UTC by Wolfgang Bangerth
Modified: 2009-08-21 21:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2009-08-18 18:56:22 UTC
This would appear to be a recent regression:
----------------------------
template <int> struct X { static const int s = 2; };

template <typename T> int f() {
  const unsigned int dim = 2;
  return X<dim>::s;
}

template int f<int>();
-----------------------------

deal.II> c++ -c -W -Wunused x.cc
x.cc: In function 'int f() [with T = int]':
x.cc:8:21:   instantiated from here
x.cc:4:22: warning: unused variable 'dim'

'dim' is used here, it just is never read from or written to.

W.
Comment 1 Wolfgang Bangerth 2009-08-20 20:40:51 UTC
Jason, might this be a result of your changes to used/unused variables?
W.
Comment 2 Jason Merrill 2009-08-21 21:46:46 UTC

*** This bug has been marked as a duplicate of 41109 ***
Comment 3 Jason Merrill 2009-08-24 21:32:18 UTC
Subject: Bug 41110

Author: jason
Date: Mon Aug 24 21:31:54 2009
New Revision: 151061

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151061
Log:
	PR c++/41109
	PR c++/41110
	PR c++/41134
	* cp-tree.h (DECL_ODR_USED): New macro.
	(struct lang_decl_base): Add odr_used flag.
	* decl.c (duplicate_decls): Propagate it.  Use it for error.
	* pt.c (register_specialization): Use it for error.
	* decl2.c (mark_used): Use it as gating flag rather than TREE_USED.
	(cp_write_global_declarations): Use it for error.
	(tree_used_ok): Remove.
	* cp-tree.h: Remove tree_used_ok.
	* call.c (build_call_a): Don't call it.
	* init.c (build_offset_ref): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wunused-17.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog