8 questions from the last 30 days
3
votes
5
answers
627
views
What is special about a ternary statement instead of a if-else statement in terms of optimization?
I'm talking from a language point of view in C or C++, where the compiler sees:
return condition ? a : b;
vs:
if (condition)
return a;
else
return b;
I've tried in my code, and both of them ...
2
votes
2
answers
143
views
Why would MSVC 2022 create two idiv calls for one std::div without any optimizations?
Using CMAKE_BUILD_TYPE="Debug" my MSVC 2022 [17.4.33403.182] produced one idiv call for the quotient and an identical idiv call for the remainder. The code was simply [see here for the ...
0
votes
1
answer
111
views
How to call inline functions by using dl library?
I have to use dl library for calling libapt-pkg functions. The method I need to call is pkgCacheFile::GetPkgCache() that is declared as inline. The problem is that dlsym returns error while trying to ...
3
votes
1
answer
75
views
Why does the compiler give strncpy 'stringop-truncation' warning only with -O2?
With avr-gcc 14, the compiler gives this warning:
avrenv.c: In function ‘main’
avrenv.c:12:13: warning: ‘strncpy’ output may be truncated copying 255 bytes from a string of length 509 [-Wstringop-...