[llvm-bugs] [Bug 40395] New: __uuidof at a template argument causes infinite template instantiation
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 21 22:30:43 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40395
Bug ID: 40395
Summary: __uuidof at a template argument causes infinite
template instantiation
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++'17
Assignee: unassignedclangbugs at nondot.org
Reporter: mail+llvm at tzik.jp
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Extra SubstNonTypeTemplateParmExpr around __uuidof causes infinite template
instantiation.
Here is a repro below. The output contains multiple instantiation of
A<&__uuidof(B)> with different AST around __uuidof.
The AST of |piid| on the second instantiation is:
| | |-TemplateArgument expr
| | | `-ConstantExpr 0x1f94990 <line:6:26> 'const _GUID *'
| | | `-SubstNonTypeTemplateParmExpr 0x1f94970 <col:26> 'const _GUID *'
| | | `-ConstantExpr 0x1f630c8 <line:10:5, col:16> 'const _GUID *'
| | | `-UnaryOperator 0x1f630b0 <col:5, col:16> 'const _GUID *' prefix
'&' cannot overflow
| | | `-CXXUuidofExpr 0x1f63080 <col:6, col:16> 'const _GUID' lvalue
And it on the third instantiation is:
| | |-TemplateArgument expr
| | | `-ConstantExpr 0x1f97678 <line:6:26> 'const _GUID *'
| | | `-SubstNonTypeTemplateParmExpr 0x1f97658 <col:26> 'const _GUID *'
| | | `-ConstantExpr 0x1f94990 <col:26> 'const _GUID *'
| | | `-SubstNonTypeTemplateParmExpr 0x1f94970 <col:26> 'const _GUID *'
| | | `-ConstantExpr 0x1f630c8 <line:10:5, col:16> 'const _GUID *'
| | | `-UnaryOperator 0x1f630b0 <col:5, col:16> 'const _GUID *'
prefix '&' cannot overflow
| | | `-CXXUuidofExpr 0x1f63080 <col:6, col:16> 'const _GUID'
lvalue
That is, the value of __uuidof is wrapped by SubstNonTypeTemplateParmExpr
multiple times, and A<&__uuidof(B)> is instantiated for each variant of wrap
level.
$ clang++ -ftemplate-depth=3 -Xclang -ast-dump -fms-extensions -fsyntax-only
-std=c++17 foo.cc
---- foo.cc ----
struct _GUID {};
struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) B {};
template <const _GUID* piid>
struct A {
virtual void baz() { A<piid>(); }
};
void f() {
A<&__uuidof(B)>();
}
----
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190122/e117d129/attachment.html>
More information about the llvm-bugs
mailing list