Install gcc on linux with no root privilege

If you want to install it as a local user GNU GSRC provides an easy way to do so Link: http://www.gnu.org/software/gsrc/ After configuration, simply specify the following commands: cd gsrc make -C pkg/gnu/gcc make -C pkg/gnu/gcc install The second step could also be changed to speed up for an N-core system: make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL=”-jN”

Double free in the C++ standard library using only std::function and std::shared_pointer

I believe the relevant part of the standard is [res.on.objects], which states If an object of a standard library type is accessed, and the beginning of the object’s lifetime does not happen before the access, or the access does not happen before the end of the object’s lifetime, the behavior is undefined unless otherwise specified. … Read more

Constexpr is not allowed in declaration of friend template specialization?

GCC is wrong here. All references are to N4431, the latest C++ WD. [tl;dr: There’s a difference between a function being inline (or more precisely, being an inline function, as defined in 7.1.2/2) and being declared with the inline specifier. The constexpr specifier makes a function inline, but isn’t an inline specifier.] Specifiers are described … Read more

How to initialize all elements in an array to the same number in C++ [duplicate]

I’m surprised at all the answers suggesting vector. They aren’t even the same thing! Use std::fill, from <algorithm>: int directory[100]; std::fill(directory, directory + 100, -1); Not concerned with the question directly, but you might want a nice helper function when it comes to arrays: template <typename T, size_t N> T* end(T (&pX)[N]) { return pX … Read more

Is “sizeof new int;” undefined behavior?

The warning doesn’t state that it’s UB; it merely says that the context of use, namely sizeof, won’t trigger the side effects (which in case of new is allocating memory). [expr.sizeof] The sizeof operator yields the number of bytes occupied by a non-potentially-overlapping object of the type of its operand. The operand is either an … Read more

Statement goto can not cross variable definition?

Goto can’t skip over initializations of variables, because the respective objects would not exist after the jump, since lifetime of object with non-trivial initialization starts when that initialization is executed: C++11 §3.8/1: […] The lifetime of an object of type T begins when: storage with the proper alignment and size for type T is obtained, … Read more

undefined reference to `boost::program_options::options_description::m_default_line_length’

If you have installed boost from repo just use -lboost_program_options that will suffice. If you installed boost libraries in some other library, you need to specify that directoty by -L/path/to/lib In CMake you may specify set(CMAKE_CXX_FLAGS “-lboost_program_options”) However with CMake you should use FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(target ${Boost_LIBRARIES})

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)