User account creation filtered due to spam.

Bug 78006 - [5/6/7/8 Regression] Segmentation fault with 'using' and generic lambda trailing return types
Summary: [5/6/7/8 Regression] Segmentation fault with 'using' and generic lambda trail...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2016-10-17 10:52 UTC by Vittorio Romeo
Modified: 2016-12-01 13:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.3.0
Known to fail: 5.4.0, 6.2.0, 7.0
Last reconfirmed: 2016-10-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Romeo 2016-10-17 10:52:28 UTC
The following code snippet causes a segmentation fault on (at least) g++ 7 and g++ 6.1:
(On Godbolt: https://godbolt.org/g/yOCXlG)

#include <type_traits>

template <typename... TFs>
auto x(TFs&&... fs)
{
    using rt = std::common_type_t<decltype(fs(0))...>;    

    // internal compiler error: Segmentation fault    
    return [](auto) -> rt { };    
}

int main()
{
    // required from here
    x([](int){})(0);    
}



---------------------



Note that getting rid of the 'using' prevents the segfault:
(On Godbolt: https://godbolt.org/g/Hoxst0)

#include <type_traits>

template <typename... TFs>
auto x(TFs&&... fs)
{    
    return [](auto) -> std::common_type_t<decltype(fs(0))...> { };
}

int main()
{
    x([](int){})(0);    
}
Comment 1 Martin Liška 2016-10-17 12:29:56 UTC
Confirmed, started with r231713.

Error message with GCC 5.3.0:

pr78006.cpp: In substitution of ‘template<class auto:1> x(TFs&& ...)::<lambda(auto:1)> [with auto:1 = int]’:
pr78006.cpp:15:19:   required from here
pr78006.cpp:9:24: error: expansion pattern ‘void’ contains no argument packs
     return [](auto) -> rt { };    
                        ^
pr78006.cpp: In function ‘int main()’:
pr78006.cpp:15:19: error: no match for call to ‘(x(TFs&& ...) [with TFs = {main()::<lambda(int)>}]::<lambda(auto:1)>) (int)’
     x([](int){})(0);    
                   ^
pr78006.cpp:15:19: note: candidate: rt (*)(auto:1) <conversion>
pr78006.cpp:15:19: note:   candidate expects 2 arguments, 2 provided
pr78006.cpp:9:24: note: candidate: template<class auto:1> x(TFs&& ...)::<lambda(auto:1)> [with auto:1 = auto:1; TFs = {main()::<lambda(int)>}]
     return [](auto) -> rt { };    
                        ^
pr78006.cpp:9:24: note:   substitution of deduced template arguments resulted in errors seen above