This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/8876] [3.4 regression] ICE in resolve_offset_ref, at cp/init.c:1824
- From: "pinskia at physics dot uc dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jul 2003 14:15:15 -0000
- Subject: [Bug c++/8876] [3.4 regression] ICE in resolve_offset_ref, at cp/init.c:1824
- References: <20021208150600.8876.benoitsevigny@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8876
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-29 14:15 -------
After fixing the code (removing f in specficed templates and adding template where
needed), the code now compiles on the mainline and also produces the correct output of:
calling function<3> -> in function<3>: l = 1, r = 2
calling function<3> -> in function<3>: l = 2, r = 1
calling function<100> -> in function<100>: l = 1, r = 2
calling function<100> -> in function<100>: l = 2, r = 1
Fixed code:
#include <stdio.h>
template<int l, int r> struct selector {
enum { SUM = l + r, CONSTANT = 100 };
};
template<int f> struct function {
template<typename L, typename R> struct special {
static void func()
{
printf("in function<%d>: l = %d, r = %d\n", f, L::PARAM, R::PARAM);
}
};
};
template<> struct function<3> {
template<typename L, typename R> struct special {
static void func()
{
printf("in function<3>: l = %d, r = %d\n", L::PARAM, R::PARAM);
}
};
};
template<> struct function<100> {
template<typename L, typename R> struct special {
static void func()
{
printf("in function<100>: l = %d, r = %d\n", L::PARAM, R::PARAM);
}
};
};
template<int l> struct object {
enum { PARAM = l };
template<int r> inline void sum(const object<r> &arg)
{
printf("calling function<%d> -> ", selector< l, r>::SUM);
function< selector< l, r>::SUM >::template special< object<l>, object<r> >::func();
}
template<int r> inline void constant(const object<r> &arg)
{
printf("calling function<%d> -> ", selector< l, r>::CONSTANT);
function< selector< l, r>::CONSTANT >::template special< object<l>, object<r>
>::func();
}
};
int main(int argc, const char *argv[])
{
object<1> obj1; object<2> obj2;
obj1.sum(obj2); // this should print: "in function<3>: l = 1, r = 2"
obj2.sum(obj1); // this should print: "in function<3>: l = 2, r = 1"
obj1.constant(obj2); // this should print: "in function<100>: l = 1, r = 2"
obj2.constant(obj1); // this should print: "in function<100>: l = 2, r = 1"
return 0;
}