gcc4.8

Gcc 4.8.3 does not spot missing 'return' keyword

半世苍凉 提交于 2021-01-28 11:11:46
问题 Let's look at such piece of code: #include <iostream> int foo(int i) {return i; } int foobar(int z) {return foo(z);} int main() { std::cout << foobar(3) << std::endl; } It compiles fine with g++ -std=c++11 ... and gives output 3. But The same output is given by: #include <iostream> int foo(int i) {return i; } int foobar(int z) { foo(z);} int main() { std::cout << foobar(3) << std::endl; } It compiles without problems but clearly the keyword return is missed in foobar. Is it a bug in gcc 4.8.3

thread_local member variable construction

…衆ロ難τιáo~ 提交于 2020-01-13 09:33:46
问题 I'm facing some strange behavior with thread_local and not sure whether I'm doing something wrong or it's a GCC bug. I have the following minimal repro scenario: #include <iostream> using namespace std; struct bar { struct foo { foo () { cerr << "foo" << endl; } int i = 42; }; static thread_local foo FOO; }; static thread_local bar::foo FREE_FOO; thread_local bar::foo bar::FOO; int main() { bar b; cerr << "main" << endl; // cerr << FREE_FOO.i << endl; cerr << b.FOO.i << endl; return 0; } With

Unknown type name ‘off64_t’

空扰寡人 提交于 2020-01-01 07:59:29
问题 I have a problem using Apache Portable Runtime on Ubuntu with GCC 4.8.1 The problem is that the off64_t from <sys/types.h> is not available when compiling with gcc . (When compiling with g++ everything work fine) Does anybody know which compiler switch to use to enable off64_t ? (I know that defining _LARGEFILE_SOURCE _LARGEFILE64_SOURCE avoids the problem, but wondering if this is the right way) To reproduce the error one can simply try to compile the following code: #include <sys/types.h>

constexpr versus template, pow function

我的未来我决定 提交于 2019-12-22 04:01:31
问题 I am experimenting new feature of the c++11, constexpr especially. If I want to code a pow with template I will simply do: //pow template<class T, std::size_t n> struct helper_pow{ inline static T pow(T const& a){ return a*helper_pow<T,n-1>::pow(a); } }; //final specialization pow template<class T> struct helper_pow<T,0>{ inline static T pow(T const& a){ return 1; } }; Now if I call my function into my code simply by: pow<double,5>(a) // where a is double the corresponding assembly will be

Compile-time equivalent to std::accumulate()

青春壹個敷衍的年華 提交于 2019-12-21 01:09:08
问题 I tried to code a basic, compile-time version of std::accumulate() by defining a class template that would recursively iterate through a given range and would add the elements at each iteration. When compiling a test program using gcc 4.8.4 on Ubuntu 14.04 , I get the following error: compile-time-accumulate.cpp: In function ‘int main()’: compile-time-accumulate.cpp:44:40: error: call to non-constexpr function ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::cbegin() const

Memory leak in gcc 4.8.1 when using thread_local?

狂风中的少年 提交于 2019-12-20 18:31:35
问题 Valgrind is reporting leaked blocks, apparently one per thread, in the following code: #include <iostream> #include <thread> #include <mutex> #include <list> #include <chrono> std::mutex cout_mutex; struct Foo { Foo() { std::lock_guard<std::mutex> lock( cout_mutex ); std::cout << __PRETTY_FUNCTION__ << '\n'; } ~Foo() { std::lock_guard<std::mutex> lock( cout_mutex ); std::cout << __PRETTY_FUNCTION__ << '\n'; } void hello_world() { std::lock_guard<std::mutex> lock( cout_mutex ); std::cout << _

GCC doesn't make use of inc

六眼飞鱼酱① 提交于 2019-12-19 06:46:11
问题 The GCC compiler $ gcc --version gcc (GCC) 4.8.2 ... doesn't generate an inc assembly instruction, where it could actually be useful, like in this C program: int main(int argc, char **argv) { int sum = 0; int i; for(i = 0; i < 1000000000L; i++) <---- that "i++" sum += i; return sum; } Instead, it generates an add instruction: 0000000000000000 <main>: 0: 31 d2 xor %edx,%edx 2: 31 c0 xor %eax,%eax 4: 0f 1f 40 00 nopl 0x0(%rax) 8: 01 d0 add %edx,%eax a: 83 c2 01 add $0x1,%edx <---- HERE d: 81 fa

GCC doesn't make use of inc

做~自己de王妃 提交于 2019-12-19 06:45:51
问题 The GCC compiler $ gcc --version gcc (GCC) 4.8.2 ... doesn't generate an inc assembly instruction, where it could actually be useful, like in this C program: int main(int argc, char **argv) { int sum = 0; int i; for(i = 0; i < 1000000000L; i++) <---- that "i++" sum += i; return sum; } Instead, it generates an add instruction: 0000000000000000 <main>: 0: 31 d2 xor %edx,%edx 2: 31 c0 xor %eax,%eax 4: 0f 1f 40 00 nopl 0x0(%rax) 8: 01 d0 add %edx,%eax a: 83 c2 01 add $0x1,%edx <---- HERE d: 81 fa

g++ Linker errors after upgrading to gcc-4.8 on Debian, libc6

拟墨画扇 提交于 2019-12-18 08:56:24
问题 I have just dist-upgraded a Debian Weezy machine to run gcc-4.8 from gcc-4.7. Previously the build environment was sane and was compiling normally. Now it gives the following linker errors, with any program (even a trivial hello world): /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug

g++ Linker errors after upgrading to gcc-4.8 on Debian, libc6

六眼飞鱼酱① 提交于 2019-12-18 08:56:01
问题 I have just dist-upgraded a Debian Weezy machine to run gcc-4.8 from gcc-4.7. Previously the build environment was sane and was compiling normally. Now it gives the following linker errors, with any program (even a trivial hello world): /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug