[cfe-dev] CXXCtorInitializer different for templated and non templated code
Lukas Vogel
lukedirtwalkerdev at gmail.com
Sun Aug 11 13:33:06 PDT 2013
Great thanks for the fast answer.
Cheers,
Lukas
2013/8/11 Eli Friedman <eli.friedman at gmail.com>
> On Sun, Aug 11, 2013 at 10:16 AM, Lukas Vogel
> <lukedirtwalkerdev at gmail.com> wrote:
> > Hi,
> >
> > I recently found out that for the following sample:
> >
> > class Pair {
> >
> > int a,b;
> >
> > public:
> >
> > Pair(int f,int s){
> >
> > a=f;
> >
> > b=s;
> >
> > }
> >
> > };
> >
> >
> > template <class T> class A : public Pair {
> >
> > A(int f, int s) : Pair(f,s){}
> >
> > };
> >
> >
> > Clang produces a ParenListExpr as init expression for the Pair(f,s) call.
> >
> >
> > However if the class A has no template parameter i.e. just class A:
> public
> > Pair{
> >
> > Clang produces a CXXConstructExpr as init expression .
> >
> >
> > Why does it matter if there is a template argument for the
> > CXXCtorInitializer ?
> >
>
> clang only builds a CXXConstructExpr when we know which constructor
> will be called. That isn't possible if the base in question is
> dependent, or if we don't know which base will be initialized. (In
> this particular case, we can tell the exact type of the base which
> will be initialized, but clang doesn't have code to reason about which
> cases are safe.)
>
> -Eli
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130811/300a7073/attachment.html>
More information about the cfe-dev
mailing list