Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [gcc-warning]

GCC is the GNU Compiler Collection, encompassing the gcc C compiler and the g++ C++ compiler, among others. It has powerful warning facilities that can reveal coding errors in C and C++ code.

gcc-warning
3 votes
2 answers
109 views

GCC 14 "possibly dangling reference to a temporary" warning or not, depending on the function argument

In the following C++ code GCC 14 with -Wall -Wextra flags produces a possibly dangling reference warning for function g(), but not f(). Why? /* getval.h */ #include <string> std::string const &...
akryukov's user avatar
-1 votes
1 answer
64 views

how to debug "*** buffer overflow detected ***: program_name terminated" along with _FORTIFY_SOURCE=2

My program crashes with the message "*** buffer overflow detected ***: program_name terminated", and I suspect it may be related to the compiler option "_FORTIFY_SOURCE=2" that I ...
user180574's user avatar
  • 5,982
0 votes
1 answer
51 views

How can I convert from .asm to .obj to .exe?

I am trying to write a simple Hello World Program using assembly and NASM. This is the code: section .data hello db 'Hello, World!', 0 ; The string to print section .text global _start ...
Θάνος Δριβάκος's user avatar
0 votes
0 answers
26 views

gcc make error on windows, how to resolve?

I'm trying to compile squid, a proxy and cache server, on windows using MinGW32 and MSYS32 for use with IIS and the make check and make install process is failing with these messages: In file included ...
chickencommander123's user avatar
2 votes
2 answers
120 views

Yet another warning: ‘<anonymous>’ may be used uninitialized

I saw many other questions about the very same warning, but my code seems different. And, over all, I get this only with -Os option. #include <iostream> using namespace std ; template <class ...
Captain'Flam's user avatar
0 votes
0 answers
72 views

Can I ask GCC to give me a warning or error on empty structs?

I just had the worst problem ever in my mixed C/C++ project. The C code is the production code, the C++ is the testing environment. We are compiling with MinGW GCC, but developing on Qt Creator which ...
Charles's user avatar
  • 1,163
1 vote
3 answers
95 views

GCC -Woverride-init warning with anonymous structs in a union

I need to define a type formed with 2 24-bit fields (48 bits in total). I didn't find a way to do it with bitfields in a struct. So I defined my type with a union and 2 anonymous structs : typedef ...
clem822's user avatar
  • 11
0 votes
0 answers
30 views

"warning: 'x' may be used uninitialized in this function ", but only for -Os

I have this piece of code. My minimal example reads: //compile with: g++ -Wmaybe-uninitialized -Os -c extern void use_x(int x); extern int get_x(bool &have_x) __attribute__((access(write_only,1)...
David G.'s user avatar
  • 670
3 votes
1 answer
122 views

Missing GCC "-Wformat" warnings for "%p" with char* etc

If I compile the following code with -std=c17 -Wall -Wextra -Wpedantic with GCC 13.2.0, I get no warnings, despite not using void* in arguments corresponding to "%p" format specifiers. #...
Wolf's user avatar
  • 9,965
2 votes
2 answers
117 views

GCC: trying to use -Werror or -pedantic using pragmas

In files being compiled using gcc (several .c and .cpp files) I have currently something like: #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic warning "-Wall" ...
ABu's user avatar
  • 11.4k
1 vote
0 answers
68 views

Neither -Wunused-result, nor --warn-unused-result generates warnings about unused results

This (simplest-example) program is set up so main() calls the makeKey() function and fails to check the return value ...Which demonstrates why, when programming, especially security critical code [I'm ...
BlueChip's user avatar
  • 160
4 votes
2 answers
123 views

GCC Format attribute not working on function pointer with "using" alias

As the ISO C++ Guidelines recommends, we should use using instead of typedef. However, recently I had to code some debug logging where the attribute would be helpful for compile-time diagnostics. When ...
SupAl's user avatar
  • 949
-5 votes
3 answers
143 views

Compiler prints HelloWorld whereas Chat GPT says it should only print Hello [closed]

Below is the code I'm compiling: #include <stdio.h> void main() { printf("Hello%cWorld\n", 0); } Below is the compiler output: HelloWorld Bing Chat-GPT response:start Below is ...
Anton's user avatar
  • 9
1 vote
0 answers
20 views

what to do if this error "storage size of `temp_q_trig1' isn't known" occurs in ST programming

I have been programming on ST for some time but I am not familiar with data types and its errors especially the compiler based ones What is that error and what is the cost of the error and how to ...
Jayanth Senthil Kumar's user avatar
0 votes
1 answer
132 views

How to resolve C printf %b format warnings

I am getting warning for below program #include <stdio.h> int main(void) { int num = 0xff; printf("%B\n", num); printf("%b\n", ~num); printf("%b\n",...
mrigendra's user avatar
  • 1,536

15 30 50 per page
1
2 3 4 5
57