[Solved] Changing gcc/g++ version causes segfault [closed]

You should try to use valgrind. Valgrind is a debugging tool only requiring for your code to be compiled with the -g flag. It’s the best way to spot segmentation fault over a program, or any memory leak. Think about using valgrind options while debugging (it’s at the bottom of the valgrind report) something like … Read more

[Solved] Using paragraphs 8.5.3p4 and p5 in the C++11 Standard, how do I prove that the snippet below doesn’t compile?

Firstly, a common mistake in reading 8.5.3p5 is to miss that it has two top level bullet points. You may have accidentally misread the final occurence of “Otherwise” as a third bullet point – but it is in fact a subpart of the second bullet point (also starting Otherwise). char a=”a”; char* p = &a; … Read more

[Solved] Accessing struct member through unique_ptr gives segmentation fault [closed]

First, std::unique_ptr is a class not a struct, so get rid of the struct prefix on the pdfInfo variable declaration. You were probably thinking of this instead: std::unique_ptr<struct Canvas::LoadedPDFInfo> pdfInfo; But even when declaring variables (or type-casting) using actual struct types, you still do not need the struct prefix. C needs that, C++ does not. … Read more

[Solved] How to self register class instances using the CRTP?

I decided to reopen the question and self answer based on Yakk’s fixes. Seems to be a more common problem (see here for example) Yakk’s example solved it: #include <cstdint> enum class CommandId : uint16_t { Command1 , Command2 , }; #include <map> #include <functional> #include <string> //#include “CommandId.h” class Registry { public: static std::map<CommandId,std::function<void … Read more