The following code compiles in all the gcc versions I tested (4.0.1, 4.1.1,
4.1.2):
template<int &i> void doit() {
i = 0;
}
template<const int &i> class X {
public:
void foo() {
doit<i>();
}
};
int i;
X<i> x;
int main(int argc, char **argv) {
x.foo();
}
Note that if "i" is declared const then the code will not compile.
--
Summary: Non-type template of type const ref accepted as a non-
const ref
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chgros at coverity dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31671