From: kanschat
-
- Here, the compiler reports
-
- template <int dim> struct Function {};
- template <int dim> struct RHS : Function<dim> { RHS() {}; };
-
- template <int dim> void f () {
- const RHS<dim> rhs;
- };
- template void f<1> ();
-
-
-
+
- x.cc: In function `void f () [with int dim = 1]':
- x.cc:7: instantiated from here
- x.cc:5: uninitialized const `rhs'
-
-
+ template <int dim> struct Function {}; + template <int dim> struct RHS : Function<dim> { RHS() {}; }; + + template <int dim> void f () + { + const RHS<dim> rhs; + }; + template void f<1> (); ++ +
Here, the compiler reports
++ x.cc: In function `void f () [with int dim = 1]': + x.cc:7: instantiated from here + x.cc:5: uninitialized const `rhs' ++
which is clearly bogus since rhs
uses the default constructor of
the class. Unfortunately, there is no way of working around the bug short of
removing the constness of the variable. We did not want to do this, since