[Bug c++/11485] New: implicit typename warning reported for wrong line
derrick at cco dot caltech dot edu
gcc-bugzilla@gcc.gnu.org
Thu Jul 10 06:37:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11485
Summary: implicit typename warning reported for wrong line
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: derrick at cco dot caltech dot edu
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
In the following code, the warning for an implicit typename is reported for the wrong line. The
code is a simplification of some code I spent an hour bashing my head on, because I kept looking
at the line the warning was reported for, instead of the correct line...
template<class T>
struct precision_trait {
enum { precisionRank = 0,
knowPrecisionRank = 0 };
};
template<class T>
struct autopromote_trait {
typedef T T_numtype;
};
template<class T1, class T2, int promoteToT1>
struct _bz_promote2 {
typedef T1 T_promote;
};
template<class T1, class T2>
struct _bz_promote2<T1,T2,0> {
typedef T2 T_promote;
};
template<class T1_orig, class T2_orig>
struct promote_trait {
typedef typename autopromote_trait<T1_orig>::T_numtype T1;
typedef typename autopromote_trait<T2_orig>::T_numtype T2;
enum {
T1IsBetter =
BZ_ENUM_CAST(precision_trait<T1>::precisionRank) >
BZ_ENUM_CAST(precision_trait<T2>::precisionRank),
knowBothRanks =
BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)
&& BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank),
knowT1butNotT2 = BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)
&& !(BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank)),
knowT2butNotT1 = BZ_ENUM_CAST(precision_trait<T2>::knowPrecisionRank)
&& !(BZ_ENUM_CAST(precision_trait<T1>::knowPrecisionRank)),
T1IsLarger = sizeof(T1) >= sizeof(T2),
defaultPromotion = knowT1butNotT2 ? _bz_false :
(knowT2butNotT1 ? _bz_true : T1IsLarger)
};
enum {
promoteToT1 = (BZ_ENUM_CAST(knowBothRanks) ? BZ_ENUM_CAST(T1IsBetter)
: BZ_ENUM_CAST(defaultPromotion)) ? 1 : 0
};
typedef typename _bz_promote2<T1,T2,promoteToT1>::T_promote T_promote;
};
template<class T>
class BrentConvergenceCriteria {
};
template<class T1, class T2, class funcT>
inline typename promote_trait<T1,T2>::T_promote
Brent(funcT f,
promote_trait<T1,T2>::T_promote value,
T1 x1, T2 x2,
BrentConvergenceCriteria<typename promote_trait<T1,T2>::T_promote> convergence
=
BrentConvergenceCriteria<typename promote_trait<T1,T2>::T_promote>()) {
}
Here is the output from g++:
Reading specs from /newman/user2/derrick/gnu/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/
specs
Configured with: ../gcc-3.3/configure --prefix=/newman/user2/derrick/gnu/gcc-3.3
Thread model: posix
gcc version 3.3
/newman/user2/derrick/gnu/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus -quiet -v -
iprefix /newman/user2/derrick/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3/ -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE brentbug.cc -D__GNUG__=3
-quiet -dumpbase brentbug.cc -auxbase brentbug -Werror -version -o /tmp/cc3AD4BO.s
GNU C++ version 3.3 (i686-pc-linux-gnu)
compiled by GNU C version 3.3.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64298
ignoring nonexistent directory "/newman/user2/derrick/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../
../../include/c++/3.3"
ignoring nonexistent directory "/newman/user2/derrick/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../
../../include/c++/3.3/i686-pc-linux-gnu"
ignoring nonexistent directory "/newman/user2/derrick/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../
../../include/c++/3.3/backward"
ignoring nonexistent directory "/newman/user2/derrick/lib/gcc-lib/i686-pc-linux-gnu/3.3/
include"
ignoring nonexistent directory "/newman/user2/derrick/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../
../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/newman/user2/derrick/gnu/gcc-3.3/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/newman/user2/derrick/gnu/gcc-3.3/include/c++/3.3
/newman/user2/derrick/gnu/gcc-3.3/include/c++/3.3/i686-pc-linux-gnu
/newman/user2/derrick/gnu/gcc-3.3/include/c++/3.3/backward
/newman/user2/derrick/gnu/gcc-3.3/include
/newman/user2/derrick/gnu/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/include
/usr/include
End of search list.
brentbug.cc:66: warning: `promote_trait<T1_orig, T2_orig>::T_promote' is
implicitly a typename
brentbug.cc:66: warning: implicit typename is deprecated, please see the
documentation for details
The error ought to be reported for line 63, not 66.
More information about the Gcc-bugs
mailing list