591: Work around a bug in g++ 4.1 and 4.2 in tests/vtypes-and-exact.cc.

https://svn.lrde.epita.fr/svn/oln/trunk/static Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Work around a bug in g++ 4.1 and 4.2 in tests/vtypes-and-exact.cc. * tests/vtypes-and-exact.cc (my_direct_type_of), (my_direct_type_of_): New macros. (my::A::foo_type, my::A::bar_type, my::A::baz_type) (my::B::foo_type, my::B::bar_type, my::B::baz_type) (my::B::quux_type, my::B::yin_type) (my::C::foo_type, my::C::quux_type, my::C::zorg_type): Rename typedefs as... (my::A::foo_t, my::A::bar_t, my::A::baz_t) (my::B::foo_t, my::B::bar_t, my::B::baz_t) (my::B::quux_t, my::B::yin_t) (my::C::foo_t, my::C::quux_t, my::C::zorg_t): ...this. Use my_direct_type_of and my_direct_type_of_ (on the exact type) instead of my_type_of and my_type_of_ (on the ``self'', current type) to work around a bug in g++ 4.1 and 4.2. (main): Adjust. * tests/Makefile.am (AM_CXXFLAGS): Rename as... (CXXFLAGS): ...this. Makefile.am | 7 ++- vtypes-and-exact.cc | 103 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 85 insertions(+), 25 deletions(-) Index: tests/vtypes-and-exact.cc --- tests/vtypes-and-exact.cc (revision 590) +++ tests/vtypes-and-exact.cc (working copy) @@ -44,6 +44,12 @@ #define my_type_of_(FromType, Typedef) \ stc_type_of_(my, my::category::my_cat, FromType, Typedef) +#define my_direct_type_of(FromExactType, Typedef) \ + typename my_direct_type_of_(FromExactType, Typedef) + +#define my_direct_type_of_(FromExactType, Typedef) \ + stc_direct_type_of_(my, my::category::my_cat, FromExactType, Typedef) + // Namespace equipment. stc_scoop_equipment_for_namespace(my); @@ -98,10 +104,33 @@ template <typename Exact> struct A : public stc::any<Exact> { + typedef A<Exact> self_t; + typedef Exact exact_t; + // Aliases. - typedef my_type_of(A, foo) foo_type; - typedef my_type_of(A, bar) bar_type; - typedef my_type_of(A, baz) baz_type; + + /* FIXME: Work around a bug that affects both g++ 4.1 and + gcc-snapshot (4.2) from Debian. The versions of the compiler + used at the moment this text was written were: + + g++ 4.1 : g++ (GCC) 4.1.2 20060920 (prerelease) (Debian 4.1.1-14) + gcc-snapshot : g++ (GCC) 4.2.0 20060922 (experimental) + + + Problem description: + + Using my_type_of (i.e., using stc_to_exact) breaks the + assertions ``Ensure stc::is_any_ works properly.'' below (in + main). Using my_direct_type_of (on the exact type) solves + this! */ +#if 0 + typedef my_type_of(self_t, foo) foo_t; + typedef my_type_of(self_t, bar) bar_t; + typedef my_type_of(self_t, baz) baz_t; +#endif + typedef my_direct_type_of(exact_t, foo) foo_t; + typedef my_direct_type_of(exact_t, bar) bar_t; + typedef my_direct_type_of(exact_t, baz) baz_t; }; @@ -144,12 +173,27 @@ template <typename Exact> struct B : public stc_get_supers(B<Exact>) { + typedef B<Exact> self_t; + typedef Exact exact_t; + // Aliases. - typedef my_type_of(B, foo) foo_type; - typedef my_type_of(B, bar) bar_type; - typedef my_type_of(B, baz) baz_type; - typedef my_type_of(B, quux) quux_type; - typedef my_type_of(B, yin) yin_type; + + /* FIXME: Same as above; using my_type_of (i.e., using + stc_to_exact) breaks the assertions ``Ensure stc::is_any_ works + properly.'' below (in main). Using my_direct_type_of (on the + exact type) solves this! */ +#if 0 + typedef my_type_of(self_t, foo) foo_t; + typedef my_type_of(self_t, bar) bar_t; + typedef my_type_of(self_t, baz) baz_t; + typedef my_type_of(self_t, quux) quux_t; + typedef my_type_of(self_t, yin) yin_t; +#endif + typedef my_direct_type_of(exact_t, foo) foo_t; + typedef my_direct_type_of(exact_t, bar) bar_t; + typedef my_direct_type_of(exact_t, baz) baz_t; + typedef my_direct_type_of(exact_t, quux) quux_t; + typedef my_direct_type_of(exact_t, yin) yin_t; }; @@ -173,10 +217,23 @@ struct C : public stc_get_supers(C) { + typedef C self_t; + typedef self_t exact_t; + // Aliases. - typedef my_type_of_(C, foo) foo_type; - typedef my_type_of_(C, quux) quux_type; - typedef my_type_of_(C, zorg) zorg_type; + + /* FIXME: Same as above; using my_type_of_ (i.e., using + stc_to_exact) breaks the assertions ``Ensure stc::is_any_ works + properly.'' below (in main). Using my_direct_type_of_ (on the + exact type) solves this! */ +#if 0 + typedef my_type_of_(self_t, foo) foo_t; + typedef my_type_of_(self_t, quux) quux_t; + typedef my_type_of_(self_t, zorg) zorg_t; +#endif + typedef my_direct_type_of_(exact_t, foo) foo_t; + typedef my_direct_type_of_(exact_t, quux) quux_t; + typedef my_direct_type_of_(exact_t, zorg) zorg_t; }; } // end of namespace my @@ -204,21 +261,21 @@ // Check types associated to A<C>. - mlc::assert_<mlc_eq(A<C>::foo_type, int)>::check(); - mlc::assert_<mlc_eq(A<C>::bar_type, double)>::check(); + mlc::assert_<mlc_eq(A<C>::foo_t, int)>::check(); + mlc::assert_<mlc_eq(A<C>::bar_t, double)>::check(); // Check types associated to B<C>. - mlc::assert_<mlc_eq(B<C>::baz_type, char)>::check(); - mlc::assert_<mlc_eq(B<C>::quux_type, long)>::check(); - mlc::assert_<mlc_eq(B<C>::yin_type, unsigned long)>::check(); + mlc::assert_<mlc_eq(B<C>::baz_t, char)>::check(); + mlc::assert_<mlc_eq(B<C>::quux_t, long)>::check(); + mlc::assert_<mlc_eq(B<C>::yin_t, unsigned long)>::check(); - mlc::assert_<mlc_eq(B<C>::bar_type, A<C>::bar_type)>::check(); + mlc::assert_<mlc_eq(B<C>::bar_t, A<C>::bar_t)>::check(); // Check types associated to C. - mlc::assert_<mlc_eq(C::foo_type, int)>::check(); - mlc::assert_<mlc_eq(C::bar_type, double)>::check(); - mlc::assert_<mlc_eq(C::baz_type, char)>::check(); - mlc::assert_<mlc_eq(C::quux_type, long)>::check(); - mlc::assert_<mlc_eq(C::yin_type, unsigned long)>::check(); - mlc::assert_<mlc_eq(C::zorg_type, double)>::check(); + mlc::assert_<mlc_eq(C::foo_t, int)>::check(); + mlc::assert_<mlc_eq(C::bar_t, double)>::check(); + mlc::assert_<mlc_eq(C::baz_t, char)>::check(); + mlc::assert_<mlc_eq(C::quux_t, long)>::check(); + mlc::assert_<mlc_eq(C::yin_t, unsigned long)>::check(); + mlc::assert_<mlc_eq(C::zorg_t, double)>::check(); } Index: tests/Makefile.am --- tests/Makefile.am (revision 590) +++ tests/Makefile.am (working copy) @@ -1,12 +1,15 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- AM_CPPFLAGS = -I$(top_srcdir)/static -I$(top_srcdir)/metalic + # FIXME: Add # -# AM_CXXFLAGS = $(CXXFLAGS_STRICT) -ggdb +# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_DEBUG) # # when oln.m4 is available in the distribution. -AM_CXXFLAGS = -O0 -ggdb +# Meanwhile, alter CXXFLAGS to turn off any optimization (Automake will +# warn against this, but that's OK). +CXXFLAGS = -O0 -ggdb check_PROGRAMS = \
participants (1)
-
Roland Levillain