Questions tagged [gcc]

17984 questions
1

votes
1

answer
203

Views

GCC Auto Vectorization

In gcc compiler is there a way to enable auto vectorization only? I do know that -ftree-vectorize flag enables auto vectorization. But it requires at least -O2 optimization level. Is there a way to enable auto vectorization without using the -O2 optimization flag? Thanks in advance.
Pasindu
8

votes
3

answer
307

Views

Move constructor for returned objects breaks C++98 code?

The Standard doesn't not require a compiler to perform return-value-optimization(RVO), but then, since C++11, the result must be moved. It looks as if, this might introduce UB to/break code, which was valid in C++98. For example: #include #include typedef std::vector Vec; struct Manager{ Vec& vec...
ead
1

votes
1

answer
38

Views

NASM automatically escaping shellcode initialized in .data [duplicate]

This question already has an answer here: Assembly: printf not printing new line 2 answers I am attempting to write a piece of assembly code which will perform operations on some shell code I have initialized in .data My initialization is as as follows: section .data shellcode: db '\x31\xc9\xf7\xe1...
Hosty
1

votes
1

answer
174

Views

How to install GCC/G++ 8 on CentOS

I'm used to install packages on Debian/Ubuntu distributions, but now I need to install gcc and g++ version 8.*. There is only version 4.* in CentOS repositories. What's the correct way to install them manually?
Eenoku
1

votes
1

answer
29

Views

Connecting to DB2/400 using GCC on Linux-PowerPC

After a lot research, I decided to ask the question here, therefore, I have not found the answer of how I can do this. I have a system written in C/C ++ which was designed for Linux PowerPC64 BE ( at now, I'm using Debian ) servers, and I need to connect this system to an IBM DB2/400 database, my fi...
Roger
20

votes
2

answer
746

Views

std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?

I have a hierarchy of base class and derived class. Base class has one virtual function which is overridden by derived class. class Base { public: ~Base(); virtual void other_functionality() = 0; }; class Derived : public Base { public: ~Derived (); void other_functionality() {/...
gaurav bharadwaj
0

votes
0

answer
3

Views

Stl_relops not found using qt-creator on linux mint

I'm trying to use qt-creator on linux but when my application is build, an error message says that usr/include/c++/7/bits/stl_relops was not found but I have it on /usr/include/c++/7/bits/stl_relops. I've edited my application.pro and included INCLUDEPATH += /usr/include/c++/7/bits/stl_relops but ev...
Felipe Paz
0

votes
0

answer
18

Views

Is relying on GCC's/LLVM's `-fexceptions` technically undefined behavior?

As far as I can tell, compiler extensions may be considered undefined rather than implementation-defined. I am guessing (but do not know for sure) that this applies to the C++ standard as well as C standard. Both GCC and LLVM offer an -fexceptions feature that appears to ensure that throwing an exce...
Kyle Strand
1

votes
2

answer
316

Views

What x86 32 bit peepholes does GCC perform?

I've been browsing through the GCC source code and I've been stumped on how to extract these. Can anyone provide a list or information on how to extract these peepholes (assembly rewrite optimizations)? GCC code: https://github.com/gcc-mirror/gcc Edit: To clarify, a 'peephole' is defined to be a fin...
Daryl
1

votes
1

answer
5.5k

Views

“is private within this context” is being thrown for function which should not be private (GCC 5.3.0, C++11)

I am attempting to create a queue, which requires the creation of another object stored in the queue. The errors are binary.cpp: In function ‘int main()’: binary.cpp:183:1: error: ‘Queue::Queue(T) [with T = binary*]’ is private Queue::Queue(T item){ ^ binary.cpp:286:65: error: within this co...
ceaston7
4

votes
2

answer
86

Views

While loop runs with an undefined function's name as a condition

Why does this code run? #include int i(); int main(){ while(i){printf('Hi');} } What exactly is the value of i that the while loop accepts? I tried printf('%d', i) and it said that i is undefined which was expected since it has only declaration, but why does while work?
Divyansh_C
1

votes
1

answer
889

Views

Properly Linking a static library with the C math library

I have a library which uses the log function from math.h. When I compile and package this library, I get no compilation errors, which is normal (I think). Now when I try to use the library in an application, gcc gives me linker errors: Compiling mytestlist using 'mytestlist.o': gcc mytestlist.o -I/s...
smac89
1

votes
2

answer
369

Views

How does GCC implement the C++ standard allocator?

I am not familiar with tracking down the source codes to figure out the GCC STL implementation (libstdc++) of the C++ standard allocator, and I cannot find any brief explanation, documentation and technical reports that describe what the memory model that GCC selects. I guess that GCC uses several f...
Kevin Dong
1

votes
1

answer
173

Views

Root cause a segmentation fault

Background I've built qemu-system-x86_64.exe on a Windows machine using MSYS2 (x86_64), and I'm debugging a segmentation fault that happens when I try to run it. Actually I don't think the problem is related to either QEMU or MSYS2, it's a problem of debugging segmentation fault and possibly wrong c...
Amir Gonnen
1

votes
1

answer
149

Views

How to get lower and higher 32 bits of a 64-bit integer for gcc inline asm? (ARMV5 platform)

I have a project on armv5te platform, and I have to rewrite some functions and use assembly code to use enhancement DSP instructions. I use a lot of int64_t type for accumulators, but I do not have an idea how to pass it for arm instruction SMULL (http://www.keil.com/support/man/docs/armasm/armasm_d...
Yevhen Tsyba
1

votes
2

answer
52

Views

What does “#APP” in the assembly file generated by compiler mean?

I wrote the following code: // a.c #include #include #include _Noreturn void _start() { register int syscall_num asm ('rax') = __NR_exit; register int exit_code asm ('rdi') = 0; // The actual syscall to exit asm volatile ('syscall' : /* no output Operands */ : 'r' (syscall_num), 'r' (exit_code)...
JiaHao Xu
1

votes
2

answer
77

Views

Newer version of GCC throws reinterpret_cast error

I am developing an embedded project (on STM32). I currently use GCC 4.9.2, but I would like to switch to newer version of my toolchain. Unfortunately my code which succesfully compiles on gcc 4.9.2, throws reinpreted_cast errors on version 6.2.0 or 7.2.0 and I have no idea why. It looks like that ne...
legier
1

votes
2

answer
50

Views

Different behavior across compilers for std::enable_if (dependent on Outer class template parameters)

I have a nested (Inner) class, for which I want to enable_if a constructor, depending on how many template parameters (Args) the enclosing class (Outer) has. I came up with the code below, only to find out that it compiles fine on some compilers, and on some not. #include #include template struct...
sthlm58
1

votes
2

answer
60

Views

Define a function which function name is masked by a macro

Sometimes, it can be handy to mask a function by a macro of same name. In this contrived example, the macros makes it possible to insert additional verification while calling function(). int function(int i); #define function(i) ( assert(i>0), function(i) ) Other more common usages make the macro tr...
Cyan
1

votes
1

answer
46

Views

gcc mingw gives garbage output when combining with assembly

My gcc:Thread model: posix gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) I'm trying to create a simple application which sums two numbers with two files saberi.c and saberi.s using gcc and intel syntax where saberi means sum. saberi.c #include int saberi(int a, int b); int m...
kingW3
1

votes
1

answer
47

Views

Previously faulting unaligned calls now working?

I'm not sure if I'm delusional, but I'm near certain calls used to fail on System V Linux x86_64 if they weren't aligned upon entry (i.e. you'd purposely disalign the stack before a call so it's aligned upon entry). For example (this now works): .data str: .asciz 'string literal' .text .globl main m...
oldjohn1994
1

votes
2

answer
60

Views

Combining two assembly files together with both text and data section

I have two assembly files, a.s and b.s I want to combine both of them and create a new assembly file c.s The file c.s should have all the code in .text of a.s and then all then code in .text of b.s I want to do the same thing with .data section # File a.s VSUB.F32 S4, S5, S6 .data .word 0x10000000 #...
Amardeep reddy
1

votes
1

answer
72

Views

stack smashing detected when no return statement in function returning non-void

I have been debugging a crash in a program which aborts with the error stack smashing detected. I have narrowed down the crash to just one function which is: static ssize_t a (const char *x, const char *y, size_t z) { #ifdef SOME_FLAG return b(x, y, z); #endif } Since I am not defining SOME_FLAG any...
sg1993
1

votes
1

answer
37

Views

What is the gcc equivilant for Xlc '-qthreaded' compiler option?

I am currently porting my compiler from AIX XLC compiler to GCC compiler on AIX. I want to know if there is an GCC equivalent compiler option available for the -qthreaded (XLC).
Nujufas
0

votes
1

answer
7

Views

Ubuntu - how to set clang as default compiler using update-alternatives

I use Ubuntu 18.04 and I have two gcc/g++ versions which are managed using update-alternatives: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 --slave /usr/bin/g++ g++ /usr/bin/g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++...
Irbis
1

votes
3

answer
91

Views

Precision of floating-point data types in C++

Why don't the precision of floating-point data types grow proportional to its size? E.g.: std::cout
Bobo Feugo
1

votes
3

answer
9k

Views

cannot find -lX11

I am trying to compile a program, and the linking fails with the following message: gcc -O2 -pipe -Wl,--export-dynamic tkAppInit.o -L/home/dimitriv/ns-allinone-2.35/tk8.5.10/unix -ltk8.5 \ -L/home/dimitriv/ns-allinone-2.35/tcl8.5.10/unix -ltcl8.5 -lX11 -ldl -lieee -lm -Wl,-rpath,/home/dimi...
user000001
5

votes
3

answer
115

Views

Is it possible to test that an abort-routine doesn't return?

I have to test a library that provides its own abort_routine() function (that calls abort() internally, but the implementation may change). One of the requirements for this abort_routine() is that it may not return. I'm wondering if it's possible to test this requirement? UPDATE: I'm not using gtest...
embedc
1

votes
0

answer
151

Views

How to avoid generation of extra assembly instruction by gcc compiler for an inline assembly function

I have two questions about generation of assembly code by gcc as a result of using inline assembly function in C file. Let me first explains my situation/code and then I will ask questions. Situation: I have defined following macro NBL2SPM which calls the mySimMagic2() function. #define NBL2SPM(comp...
NUM
1

votes
1

answer
1.4k

Views

'CXXABI_1.3.11' not found`

I can't get a cross compiled build running on my Raspberry Pi 1 B+. The error I keep getting is: ImportError: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version 'CXXABI_1.3.11' not found. I tried multiple compilers with different settings but I keep getting the same error. Also changing the LD_LI...
Sam
1

votes
1

answer
123

Views

tried to install a pythonn package but encountered “cannot find -lgcc_s” error

Hi I was trying to install a python package called 'pysptk' under the Ubuntu 16.04, but when I use: pip install pysptk I have encountered the following error. /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1 However, I alread...
Luke
1

votes
0

answer
236

Views

Cross compiling gcc for Android

I am trying to cross compile gcc for Android using a toolchain generated by buildroot. ./configure --prefix=/home/Desktop/gcc_5/build/ CC=/home/buildroot-2017.02-rc3/output/host/usr/bin/aarch64-buildroot-linux-uclibc-gcc CXX=/home/buildroot-2017.02-rc3/output/host/usr/bin/aarch64-buildroot-linux-ucl...
Doha
1

votes
0

answer
825

Views

gcc: fatal error: no input files when compiling and linking a resource file with Code::Blocks

I grow tired from badly-made non-working or unnecessarily obfuscated user-hostile tools and programs. I am using Code::Blocks set to compile with Cygwin GCC (Compiler toolchain directory: C:\msys64\usr), I add a .rc file within my project and then when I compile I get this: === Build: Debug in Test...
1

votes
0

answer
89

Views

Bypass the faulty gcc “-mcygwin” argument, when building a library on python-3.4 on windows, through cygwin

I have the following problem: I want to build an external library of python on Windows through a script that uses gcc. When the script reaches the command: python setup.py build --compiler=cygwin, the following command is generated (that crashes): C:\cygwin64\bin\gcc.exe -mcygwin -mdll -O -Wall...
John Sig
1

votes
1

answer
59

Views

gcc showing errors from system library. -isystem doesnt work

Here is a simple (Deliberately wrong) c++ hello world program(https://pastebin.com/Cehm9yLx) #include using namespace std; int main() { int a; cout >> 'Hello World! Welcome!'
user9180468
1

votes
1

answer
84

Views

What are the temporary 'object' files (with alphanumeric file extensions) that are created during C compilation?

When I compile my C program I get certain files that are created temporarily for each object file. These temporary files are entitled utilities.o-fb62414b etc (i.e. something.o-suffix where 'something' is my object file and the suffix is alpha numeric characters). I can't find a description of the...
p-robot
1

votes
0

answer
510

Views

How do install gcc 4.4 and g++ 4.4 on Fedora 27

I have Fedora 27 and will compile a applicationh with gcc4.4 and g++4.4. But i can not install this version with yum or with update-alternatives Can you help me
jdeb
1

votes
1

answer
27

Views

Command line arguments to get total errors during compilation in gcc compiler

Is there any command line argument to list the total number of errors in the particular compilation. This would be useful when solving a hell lot of errors or when the sources are large in number. IDE's like Eclipse used to list the total number of errors and warnings.
iamnagaky
1

votes
0

answer
173

Views

Define a variable for linker in a Makefile

I use for gcc for compiling. In the ldscript, I have such a definition : STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x1000; I would like to define STACK_SIZEvariablz in a Makefile How should I proceed ? I ve tried this : STACK_SIZE=0 LDFLAGS = -DSTACK_...
Pierre Godicheau
1

votes
0

answer
61

Views

Is there an equivalent of link_warning(symbol) for C++?

Is it possible to define a C++ class method that would compile cleanly but produce a warning message when used, in a way similar to the unimplemented C library functions? Something like: int MyClass::frobnicate() { link_warning(frobnicate, 'function not implemented'); return 0; } An __attribute__((...
Dmitry Grigoryev

View additional questions