gcc4.9

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

跟風遠走 提交于 2019-11-29 15:31:05
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' from 'double' to 'int' inside { } [-Wnarrowing] Removing the -std=c++11 flag results in a warning regarding the brace init, but not any narrowing: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 On the other hand, g++5 doesn't

Is memcpy(&a + 1, &b + 1, 0) defined in C11?

↘锁芯ラ 提交于 2019-11-29 05:25:32
This question follows this previous question about the definedness of memcpy(0, 0, 0) , which has been conclusively determined to be undefined behavior. As the linked question shows, the answer hinges on the contents of C11's clause 7.1.4:1 Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, […]) […] the behavior is undefined. […] The standard function

gcc-4.9 Undefined Behavior Sanitizer

风格不统一 提交于 2019-11-28 17:13:54
In gcc-4.9 changes it says: UndefinedBehaviorSanitizer (ubsan), a fast undefined behavior detector, has been added and can be enabled via -fsanitize=undefined. Various computations will be instrumented to detect undefined behavior at runtime. UndefinedBehaviorSanitizer is currently available for the C and C++ languages. I looked at this question ( A C++ implementation that detects undefined behavior? ) but it seems fairly outdated. This link ( http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00264.html ) has some information on it, but it's several months old. This is an attempt to add the

How do I compile and run GCC 4.9.x?

南笙酒味 提交于 2019-11-27 18:19:29
问题 I'm running debian wheezy and wanted to upgrade from GCC 4.7.2 to GCC 4.9.0. As per these instructions I installed libgmp-dev , libmpfr-dev and libmpc-dev (my package manager gave me versions 2:5.0.5+dfsg-2, 3.1.0-5 and 0.9-4 respectively) and ran the following to compile gcc (note that in my case it was 4.9.0 instead of 4.6.2): tar xzf gcc-4.6.2.tar.gz cd gcc-4.6.2 ./contrib/download_prerequisites cd .. mkdir objdir cd objdir $PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 make make

gcc-4.9 Undefined Behavior Sanitizer

纵饮孤独 提交于 2019-11-27 10:17:45
问题 In gcc-4.9 changes it says: UndefinedBehaviorSanitizer (ubsan), a fast undefined behavior detector, has been added and can be enabled via -fsanitize=undefined. Various computations will be instrumented to detect undefined behavior at runtime. UndefinedBehaviorSanitizer is currently available for the C and C++ languages. I looked at this question (A C++ implementation that detects undefined behavior?) but it seems fairly outdated. This link (http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00264

What is happening here in pow function?

ⅰ亾dé卋堺 提交于 2019-11-27 09:27:59
I have seen various answer here that depicts Strange behavior of pow function in C. But I Have something different to ask here. In the below code I have initialized int x = pow(10,2) and int y = pow(10,n) (int n = 2) . In first case it when I print the result it shows 100 and in the other case it comes out to be 99 . I know that pow returns double and it gets truncated on storing in int , but I want to ask why the output comes to be different. CODE1 #include<stdio.h> #include<math.h> int main() { int n = 2; int x; int y; x = pow(10,2); //Printing Gives Output 100 y = pow(10,n); //Printing

version `CXXABI_1.3.8' not found (required by …) [duplicate]

梦想的初衷 提交于 2019-11-27 03:33:27
This question already has an answer here: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found [closed] 8 answers When I run my program following a compile, I get the following error: ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found (required by ./prog) ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.19' not found (required by ./prog) ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/arman/lib/boost_1_55_0/stage/lib/libboost_serialization.so.1.55.0) I have both

Difference between std::regex_match & std::regex_search?

时光毁灭记忆、已成空白 提交于 2019-11-26 18:53:44
Below program has been written to fetch the "Day" information using the C++11 std::regex_match & std::regex_search . However, using the first method returns false and second method returns true (expected). I read the documentation and already existing SO question related to this, but I do not understand the difference between these two methods and when we should use either of them? Can they both be used interchangeably for any common problem? Difference between regex_match and regex_search? #include<iostream> #include<string> #include<regex> int main() { std::string input{ "Mon Nov 25 20:54:36

version `CXXABI_1.3.8' not found (required by …) [duplicate]

女生的网名这么多〃 提交于 2019-11-26 17:31:14
问题 This question already has an answer here: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found [closed] 8 answers When I run my program following a compile, I get the following error: ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found (required by ./prog) ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.19' not found (required by ./prog) ./prog: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found

Is auto as a parameter in a regular function a GCC 4.9 extension?

社会主义新天地 提交于 2019-11-26 15:31:57
gcc 4.9 allows the following code, but gcc 4.8 and clang 3.5.0 reject it. void foo(auto c) { std::cout << c.c_str(); } I get warning: ISO C++ forbids use of 'auto' in parameter declaration [-Wpedantic] in 4.9 but in 4.8 and clang I get error: parameter declared 'auto' . Yes, this is an extension. It's likely to be added to C++17 as part of the 'concepts' proposal, I believe. This is Concepts Lite speak for template<class T> void foo(T c) { std::cout << c.c_str(); } The auto just replaces the more verbose template<class T> . Similarly, you can write void foo(Sortable c) as a shorthand for