[Bug c++/102084] New: Segfault when lambda is missing return type
loximann at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Aug 26 16:28:31 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102084
Bug ID: 102084
Summary: Segfault when lambda is missing return type
Product: gcc
Version: 11.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: loximann at gmail dot com
Target Milestone: ---
The following program crashes:
--------------------------------------------------------------
#include <functional>
#include <iostream>
#include <tuple>
template <typename T>
std::function<T()> constant(const T& c) {
return [c]() noexcept { return c; };
}
template <typename T>
std::function<const T&()> constant_ref(const T& c) {
return [c]() noexcept -> const T&{ return c; };
}
template <typename T>
std::function<const T&()> constant_ref_broken(const T& c) {
return [c]() noexcept { return c; };
}
int main() {
std::cout << constant(1.0)() << std::endl;
std::cout << constant_ref(1.0)() << std::endl;
std::cout << constant_ref_broken(1.0)() << std::endl;
}
--------------------------------------------------------------
More information about the Gcc-bugs
mailing list