https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118538
--- Comment #15 from Disservin <disservin.social at gmail dot com> ---
Here's a smaller reproduction btw
cat test.cpp && g++ -O0 -std=c++17 -Wall -Wextra -Wpedantic -Wuninitialized
-fno-strict-aliasing -fwrapv -g3 test.cpp && ./a.out
#include <fstream>
class StreamParser {
public:
StreamParser(std::istream &stream) : stream_buffer(stream) {}
private:
class StreamBuffer {
private:
static constexpr ::size_t N = 1024;
public:
StreamBuffer(std::istream &stream) : stream_(stream) {}
private:
std::istream &stream_;
char buffer_[N * N];
};
StreamBuffer stream_buffer;
};
class Reader {
public:
Reader(const std::string , int ) {
std::ifstream file;
throw 42;
StreamParser parser(file);
}
};
int main() { auto reader = Reader("file", 1); }
test.cpp: In function ‘int main()’:
test.cpp:28:19: warning: variable ‘reader’ set but not used
[-Wunused-but-set-variable]
28 | int main() { auto reader = Reader("file", 1); }
| ^~~~~~
[1] 1182995 segmentation fault (core dumped) ./a.out