42,290 questions
0
votes
0
answers
28
views
C++20 modules with GCC and Clang/Eclipse CDT LSP Editor
My project defines a module ocr, imports std and includes headers from a few libraries, for example:
module;
#include <httplib.h>
#include <tesseract/baseapi.h>
#include <leptonica/...
1
vote
0
answers
38
views
x86: How to obtain return address from %ebp?
Similar question: Assembly return address
I want to write a function to print the return address of the current function. This is code that prints %ebp+4:
void backtrace() {
int ebp;
asm ("movl %%...
0
votes
1
answer
48
views
GCC+CMake, static lib changes size_t footprint
While refactoring some legacy code I ran into some strange behaviour of CMake+GCC that I can not explain or correct.
This is what I have:
Debian Trixie with GCC 14.2.0 and CMake 3.31.6
A test project ...
180
votes
8
answers
396k
views
What does the error "hdealt::hdealt() is implicitly deleted because default definition would be ill-formed:uninitialized non-static const member" mean
I've been working on some C++ code that a friend has written and I get the following error that I have never seen before when compiling with gcc4.6:
error: use of deleted function
‘GameFSM_<std::...
35
votes
3
answers
12k
views
How to detect if building with address sanitizer when building with gcc 4.8?
I'm working on a program written in C that I occasionally build with address sanitizer, basically to catch bugs. The program prints a banner in the logs when it starts up with info such as: who built ...
18
votes
2
answers
14k
views
Why does the std module fail to compile with gcc?
The following test program
import std;
int main() {}
compiled with gcc-14
/usr/local/bin/g++ -g -std=c++23 -fconcepts -fmodules-ts -O3 -Wall -Wextra test400.cc --output test400
gives the following ...
9
votes
3
answers
32k
views
"Candidate function not viable" from g++/gcc compiler. What is wrong here?
I'm trying to compile my main.cpp, but I keep getting this error for two hours now. The issue here is to pass a function as a parameter but I think I'm doing something wrong. The compiler says it ...
7
votes
5
answers
3k
views
c++ implicit conversion from double to bool is dangerous
This is the second time I make a big mistake, by creating a variable of type bool instead of a double. For example consider
double f()
{
return true;
}
bool something()
{
return 0.0;
}
...
5
votes
3
answers
222
views
Log2 implementation with cygwin64 seems inefficient
I noticed there was a double precision divide after all log2 calls when using cygwin64 3.6.4 and using compiler options -O3 and
-D_FILE_OFFSET_BITS=64 so I wrote a small program to illustrate it. ...
0
votes
1
answer
88
views
gcc 15.0.2+mingw 13.0.0 libstdc++-v3 build error
I'm trying to build mingw 13.0.0 with gcc 15.0.2 toolchain on Windows using another mingw 13.0.0 with gcc 15.0.2 build under busybox shell. As described in this tutorial, I first configured, built and ...
1
vote
0
answers
86
views
How do I configure VSCode IntelliSense to use my local GCC trunk build?
I have built GCC 16.0 trunk in order to test out the new C++26 reflection capabilities. I am developing using WSL (Ubuntu) and VSCode.
As it stands, I have the following basic example in a simple ...
0
votes
0
answers
90
views
Linkage error using STD on Windows GCC 15.2.0
I follow How to use module `std` with gcc to generate "gcm.cache/std.gcm" on Windows using GCC 15.2.0 and ran g++ -std=c++23 -fmodules -fsearch-include-path -c bits/std.cc at "C:\bak\...
1
vote
0
answers
35
views
Inline Assembly Bug in gcc? [duplicate]
The code in question
void _start() {
const char msg[] = "Hello, World!\n";
long ret;
__asm__ volatile (
"mov $1, %%rax\n"
"mov $1, %%rdi\n"
...
0
votes
1
answer
214
views
Why __FILE__ does not print the full path (even with gcc)
I am writing a logging utility in C and want __FILE__ to print the full absolute path to the source file:
/home/j/OSL/Separate.c
But it still prints a relative path:
../Separate.c
even though I am ...
3
votes
2
answers
1k
views
When generating code for arm64, why do gcc + clang use adrp+add rather than adr for addressing nearby variables?
With arm64, a literal for a nearby address can be loaded into a register with the adr instruction. According to the ARM-V8 Architecture Reference Manual the adr instruction:
ADR <Xd>, <label&...