FAQ Database Discussion Community


Exception thrown by 'stol' using Visual Studio but not gcc

c++,c++11,exception,visual-studio-2013,gcc4.9
The following code throws an exception when it is run under Visual Studio 2013 but not gcc 4.9.2. The error reported is: 'exception: stol argument out of range' stol returns a long so the size of temp should be big enough to hold the returned value. Can anyone explain the...

g++49 and g++5 different behaviour when narrowing in initializing list

c++,c++11,gcc4.9,gcc5
Consider this code: #include <iostream> int main() { int i{10.1}; // narrowing, should not compile std::cout << i << std::endl; } According to the C++11 standard, it should not compile (narrowing in brace initialization is forbidden.) Now, compiling with g++4.9.2 -std=c++11 only emits a warning warning: narrowing conversion of '1.01e+1'...

Pkg-config 0.28 did not build on OSX 10.10.2

homebrew,osx-yosemite,pkg-config,gcc4.9
Recently I clean installed Yosemite 10.10.2 I also installed gcc using brew install gcc Now I'm trying to build and install python and openmpi from source because previously I've had problems with gfortran and clang. So I did brew install openmpi --build-from-source -verbose brew install python --build-from-source -verbose with variables...

Never-ending quicksort

c,infinite-loop,quicksort,gcc4.9
I tried to implement a quicksort on arrays of int64_t like this: void quicksort (int64_t *array,size_t size) { int64_t *split; size_t i=0; size_t j=size-1; if (size>1) { split=({ int64_t p=array[0]; do { for (;array[i]<p;i++); for (;array[j]>p;j--); swap(array[i],array[j]); } while (i<j); swap(array[i],array[j]); swap(array[j],array[size]); &(array[j]); })-1; quicksort(array,j-1); quicksort(split+1,size-j); } return; } Which...

R 3.2, GCC, and homebrew

r,gcc,homebrew,gcc4.9
I recently needed to install R 3.2 to get a package from Bioconductor working, but after I installed, I get the following error: [16:16:11 20] $ r dyld: Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib Referenced from: /usr/local/Cellar/r/3.2.0/R.framework/Versions/3.2/Resources/lib/libR.dylib Reason: image not found Trace/BPT trap: 5 Sure enough, brew was set to use gcc...

Capture this in lambda attribute inside a templated class vs not-templated class

c++,templates,c++11,lambda,gcc4.9
I have succeeded writing a class like this one, capturing this in a lambda defined as non-static attribute of said class: #include <memory> #include <iostream> #include <functional> struct S { S() { std::cout << "S::S()[" << this << "]" << std::endl; } std::string y_{"hi mate"}; int x_; std::function<void(int*)> del_{[this](int *ptr)...