Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Parameter default values of forward-declared template classes with template parameter packs don't PCH roundtrip #25270

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR25271
Status NEW
Importance P normal
Reported by Jannis Harder (jix@jixco.de)
Reported on 2015-10-21 08:28:47 -0700
Last modified on 2015-10-22 08:58:07 -0700
Version trunk
Hardware PC Linux
CC jix@jixco.de, kfunk@kde.org, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments clangbugtest.tar (10240 bytes, application/x-tar)
clang-fix-25271-template-param-defaults-before-pack-deserialize.patch (596 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 15131
tar of cpp file, header file and shell script to reproduce the bug

When having a forward declaration like this

    template<unsigned T=123, unsigned... U> class dummy;

in a header file that also contains the class definition, using dummy<> fails
with

    error: too few template arguments for class template 'dummy'

when using a precompiled header, even though it works fine otherwise (as it
should).

The bug applies to integer template parameters (as in the given example) as
well as to typename parameters.
The bug doesn't apply to class templates without forward declaration.
The bug also doesn't apply to class templates without a following parameter
pack.

A real world example that triggers this is using gsl::array_view<int> from:

https://github.com/Microsoft/GSL/blob/master/include/array_view.h

I tested with 3.7.0 and svn trunk, which both are affected.
Quuxplusone commented 8 years ago

Attached clangbugtest.tar (10240 bytes, application/x-tar): tar of cpp file, header file and shell script to reproduce the bug

Quuxplusone commented 8 years ago

Attached clang-fix-25271-template-param-defaults-before-pack-deserialize.patch (596 bytes, text/plain): patch fixing the problem in ASTReaderDecl.cpp