Questions tagged [gcc]

GCC is the GNU Compiler Collection. It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well.

GCC is the GNU Compiler Collection, a collection of free software compilers. It is a key component of the GNU Toolchain.

GCC includes an optimizing C compiler that is the most commonly used C compiler on Linux. GCC also includes front ends for C++ (including full support for C++17), Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++, libgfortran, ...). It supports many architectures.

GCC sources are available via the Git repository. Major decisions about GCC are made by the steering committee, guided by the mission statement.

See also GCC online documentation and the home page, and release dates.

40905 questions
19
votes
3 answers

Strange GCC compile error (simple example included)

it's a pretty basic question but I don't understand why the code below does not compile on GCC 4.6.1. It does compile on VS 2008 with SP1: #include class MyClass { public: const static int MinValue = -1000; const static int…
David Williams
  • 753
  • 1
  • 4
  • 11
19
votes
3 answers

How does gcc implement stack unrolling for C++ exceptions on linux?

How does gcc implement stack unrolling for C++ exceptions on linux? In particular, how does it know which destructors to call when unrolling a frame (i.e., what kind of information is stored and where is it stored)?
Geoffrey Irving
  • 6,483
  • 4
  • 32
  • 40
19
votes
2 answers

C++ static initialization vs __attribute__((constructor))

Example: struct Foo { Foo() { printf("foo\n"); } }; static Foo foo; __attribute__((constructor)) static void _bar() { printf("bar\n"); } Is it deterministic wether foo or bar is printed first? (I hope and would expect that constructors of static…
Albert
  • 65,406
  • 61
  • 242
  • 386
19
votes
1 answer

Ambiguous constructor overload on GCC, but not on Clang

Let's say we have the following simple code: #include #include struct S { template explicit S(T) noexcept requires std::is_signed::value { std::cout << "T\n"; } template
apopa
  • 405
  • 2
  • 12
19
votes
1 answer

Does C++ standard guarantee the initialization of padding bytes to zero for non-static aggregate objects?

Does C++ support a language construct that will allow us to initialize an object and all its padding fields to zero. I found some encouraging wording in cppreference.com about zero-initialization that suggests that on some conditions, the padding…
Shriram V
  • 1,500
  • 2
  • 11
  • 20
19
votes
1 answer

CMAKE_C_COMPILER not set, after EnableLanguage

I installed CMake on windows in addition to gcc and g++ compiler I added the variables to the path but still getting the following error could you please help. -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:6 (project): Running …
Anas Hosami
  • 317
  • 1
  • 2
  • 6
19
votes
6 answers

Link-time optimization and inline

In my experience, there's lot of code that explicitly uses inline functions, which comes at a tradeoff: The code becomes less succinct and somewhat less maintainable. Sometimes, inlining can greatly increase run-time performance. Inlining is…
ccom
  • 351
  • 1
  • 3
  • 8
19
votes
2 answers

Format no such file or directory

I was trying to use the C++ format utility (std::format). I tried to compile this simple program: #include int main() { std::cout << std::format("{}, {}", "Hello world", 123) << std::endl; return 0; } When I try compiling with g++…
cael ras
  • 361
  • 1
  • 2
  • 12
19
votes
1 answer

Simple example where [[likely]] and [[unlikely]] affect program assembly?

C++20 introduced the attributes [[likely]] and [[unlikely]] to the language, which can be used to allow the compiler to optimize for the case where one execution path is either much more likely or much less likely than the other ones. Given the…
Alecto Irene Perez
  • 10,321
  • 23
  • 46
19
votes
3 answers

Get type name as string in C, GCC

Is there some 'builtin' extension in GCC to get type name of expression in C? (As a string, i.e. 'const char*').
dilettant
  • 399
  • 2
  • 6
19
votes
2 answers

Testing a Code-Generator Optimization

I have written a low-level optimization for the LLVM code-generator backend. Basically, the optimization will reorder assembly instructions at the basic block level to allow a later (existing) optimization to more efficiently optimize the resultant…
Zeke
  • 1,974
  • 18
  • 33
19
votes
5 answers

how to succesfully compile python 3.x

Upon attempting to compile python 3.7 I hit Could not import runpy module: jeremyr@b88:$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz .... jeremyr@b88:~/Python-3.7.3$ ./configure --enable-optimizations …
jeremy_rutman
  • 3,552
  • 4
  • 28
  • 47
19
votes
5 answers

Detect ICC vs GCC at compile time

How to detect at compile time if I'm using gcc or icc? (I was quite puzzled to find out that icc defines __GNUC__ -- and even __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ ! why?)
Znorg
  • 681
  • 1
  • 7
  • 19
19
votes
2 answers

Is it safe to link gcc 6, gcc 7, and gcc 8 objects?

Is it safe to link C++17, C++14, and C++11 objects asks about linking objects compiled with different language standards, and Jonathan Wakely's excellent answer on that question explains the ABI stability promises that gcc/libstdc++ make to enusure…
Barry
  • 286,269
  • 29
  • 621
  • 977
19
votes
5 answers

Unions, aliasing and type-punning in practice: what works and what does not?

I have a problem understanding what can and cannot be done using unions with GCC. I read the questions (in particular here and here) about it but they focus the C++ standard, I feel there's a mismatch between the C++ standard and the practice (the…
L.C.
  • 1,098
  • 10
  • 21
1 2 3
99
100