Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-11-11 15:04:04


On Thu, Nov 11, 2004 at 04:37:53PM +0100, Christoph Ludwig wrote:
> On Thu, Nov 11, 2004 at 10:07:43AM -0500, David Abrahams wrote:
> > Christoph Ludwig <cludwig_at_[hidden]> writes:
[...]
> > > However, the regression tests report that gcc 3.4 passes the
> > > is_abstract test. The reason is that above error is triggered only if
> > > A<int> is not instantiated by the compiler; but is_abstract_test.cpp
> > > does not test class template specializations at all.
> >
> > Why don't we just get is_abstract to cause the instantiation? It
> > seems to me that you'd need to do that anyway in order to detect
> > abstractness. As a matter of fact, I have some doubts about your
> > diagnosis, since I can't imagine any way that is_abstract could work
> > without doing the instantiation.

attached is:

1) a corrected version of is_abstract_template_test.cpp

   When I prepared the original version I did not realize that
   is_abstract<T&>::value is supposed to be false for any type T.

2) a patch to boost/type_traits/is_abstract.hpp that works around gcc
   bug #17232.

   I would not be surprised if my patch turns out to be overly
   complicated. I had assumed that any expression that involves
   sizeof(T) causes the instantiation of T if T is a template
   specialization. So I tried, e.g., to add the condition
   sizeof(T) > 0 to the parameter list of ice_and in is_abstract_imp.
   For some reason, though, whatever I tried showed no effect.
   (Perhaps the compiler realized that the conditions I added were
   true for any type T and eliminated the evaluation of sizeof(T)?)

   I finally settled for attached patch that adds a further struct in
   which SFINAE is used again.

With this patch gcc 3.4.2 passes both is_abstract_test.cpp as well as
the attached is_abstract_template_test.cpp.

I still would like to see something like is_abstract_template_test.cpp
added to the type_traits tests. It is easy to introduce subtle bugs
both in the compiler when implementing SFINAE and template
instantiation as well as in the code relying on SFINAE.

Regards

Christoph

-- 
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html





Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk