41,980
questions
3
votes
1
answer
68
views
Is warning yielded by -Wc++-compat about identifiers not yet expanded by macro a false positive?
I've been compiling my C code against some very "non-default" warnings and found a potential GCC bug - a false positive caused by -Wc++-compat. Before explaining anything, it would probably ...
-1
votes
0
answers
30
views
Class declaration in cpp file does not work in static library [duplicate]
I am trying to use ramulator2 with a simple change. It is built as a shared library, and when tested it works fine. For reasons beyond this question, I want it as a static library. I thought this was ...
1
vote
0
answers
101
views
Why g++ does not optimize this code removing the division (s / s)?
code example compiled with -O3 and -fno-inline in godbolt: https://godbolt.org/z/4rvxccsns
template <class T>
T numbbo(T r, unsigned s) {
return 10.0 / (static_cast<float>(s) / ...
1
vote
0
answers
50
views
How to improve gcc compile time for compile-once single file program
GCC version: 11.4.0
Flags I am passing: -O3 -march=native -funroll-all-loops -mprefer-vector-width=512 -mavx
I have a C program that looks like this:
void foo(...) {
for (int i...)
for (int j...)...
1
vote
4
answers
76
views
Make constant array visible to different source file
Is it possible to make contents of constant array be visible across multiple other source files so that compiler can optimize access to the array.
I have an array const int myTable[10]; and in ...
1
vote
2
answers
99
views
What is the rationale for 0-size arrays?
Both GCC and Clang support (as an extension) 0-size (also called "0-length") arrays.
What is the rationale for 0-size arrays (example int x[0])?
0
votes
0
answers
18
views
how to fix clang: error: -lm: 'linker' input unused [-Werror,-Wunused-command-line-argument]? [duplicate]
I downloaded homebrew, gcc14 and pasted the path on compiler.
Then it worked when I pasted the flags:
-DCMAKE_C_FLAGS="-Wall -Werror -pedantic-errors -lm -g"
But it didn’t build and showed:...
0
votes
2
answers
118
views
GCC Output Symbol not Relocatable with -fPIC
On an Ubuntu 24.04, using the default GCC-13.2 compiler I compiled
a source file with -fPIC option to produce relocatable binary:
/usr/bin/c++ -v -DBPFTIME_BUILD_WITH_LIBBPF=1 -DSPDLOG_COMPILED_LIB
-...
0
votes
0
answers
31
views
Issues with GCC / G++ in cuda 11.7
I am having problems with CUDA extension, I've been trying to run several deep learning models that require C. As always the first step with these models is to run setup.py but I keep encountering the ...
0
votes
1
answer
45
views
Issue with DWARF DIE's and tracking variables
My compiler is writing DWARF DIE's and I am currently coming across an issue with tracking variables.
For example, the abbreviation would look something like:
DW_AT_name DW_FORM_string
...
2
votes
2
answers
95
views
Why am I getting "Assuming signed integer overflow does not occur" here?
Code in question (godbolt)
#include <stdbool.h>
void do_work(void);
typedef struct task {
int timer;
void (*job)(void);
} task_t;
typedef struct task_list {
task_t *tasks;
int ...
0
votes
0
answers
57
views
Issues with using * in command line in windows [duplicate]
I was trying to solve the reverse polish calculator problem where the arguments can be entered on the command line. I am facing a peculiar problem. The program name is rpc.exe
A command line entry as ...
1
vote
1
answer
78
views
vectorisation fails due to unsupported control flow in loop
I have some C code that looks like (The full code on Compiler-Explorer: https://godbolt.org/z/aTGac8fco):
void foo(const float *restrict const input,
float *restrict const output,
...
0
votes
1
answer
45
views
ARM stack padding generated by compiler
The following function,
#include <string.h>
void func1(char *s)
{
char buffer[4];
strcpy(buffer, s);
}
is compiled,
$ arm-linux-gnueabi-gcc -g -fno-stack-protector func1.c -c -o func1.o
$...
0
votes
1
answer
55
views
Install GCC and G++ on Windows in a GitHub Actions CI/CD Workflow
I'm setting up a GitHub Actions CI/CD workflow and need to install gcc and g++ on a Windows runner to compile C/C++ code. I want the installation to be fully automated, as part of the CI/CD pipeline, ...