Topic: is a global template function with a local struct definition legal c++?
Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1999/07/12 Raw View
"Allen Broadman" <allenbro@ix.netcom.com> writes:
> I'm trying to find out if the following code is legal C++:
[code removed]
Yes, it is.
> The code generates INTERNAL COMPILER ERROR in MSVC 6.0.
[...]
> I have no reason to believe that the construct is not legal, and I suspect
> the problem is MSVC
If it produces an internal error, it is definitely a compiler
problem. A compiler should not crash, even if presented illegal code.
Regards,
Martin
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Allen Broadman" <allenbro@ix.netcom.com>
Date: 1999/07/10 Raw View
I'm trying to find out if the following code is legal C++:
template<typename T>
void foo(T param)
{
struct local
{
int i;
void bar() {}
};
}
int main(int argc, char *argv[])
{
foo(1L);
return 0;
}
The code generates INTERNAL COMPILER ERROR in MSVC 6.0. This occurs if foo
is a template function AND if struct local contains a method definition. If
either of those conditions is removed, the code compiles and works.
I have no reason to believe that the construct is not legal, and I suspect
the problem is MSVC, but I thought maybe someone in this group could confirm
this...
Thanks,
Allen Broadman
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]