LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 42936 - SegFault with __builtin_bit_cast to templated type and auto return type
Summary: SegFault with __builtin_bit_cast to templated type and auto return type
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-08 10:21 PDT by Roland Schulz
Modified: 2019-08-12 11:31 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s): r368600


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Schulz 2019-08-08 10:21:22 PDT
template<class T> struct S { int x;};
auto f() {
    int t = 5;
    return __builtin_bit_cast(S<int>, t);
}

Error:
1.	<source>:8:41: current parser token ';'
2.	<source>:6:10: parsing function body 'f'
3.	<source>:6:10: in compound statement ('{}')
 #4 0x0000557591fc2a05 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-trunk-20190808/bin/clang-10+0x47d8a05)
clang-10: error: unable to execute command: Segmentation fault (core dumped)

https://godbolt.org/z/4sPmp2
Comment 1 Richard Smith 2019-08-08 13:52:00 PDT
Reduced slightly:

template<class T> struct S { int x;};
S<int> x = __builtin_bit_cast(S<int>, 0); 

Looks like we're missing a RequireCompleteType call?
Comment 2 Erik Pilkington 2019-08-12 11:31:48 PDT
Fixed in 368600.