863 questions
0
votes
0
answers
34
views
VS Code not printing warnings
I'm trying to set up VS Code to learn C++. I downloaded the latest version of the compiler (g++) and tried running the following simple code, which (if I understand this correctly) should print a &...
-2
votes
1
answer
309
views
GCC warning: 'memcpy' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807
Compiling Lua (version 5.4.7) with the GCC 15.2.0 compiler as C++, I get a strange warning message
...\lauxlib.c|586|warning: 'memcpy' specified bound 18446744073709551614 exceeds maximum object size ...
1
vote
1
answer
77
views
Level of type casting of pointers?
I have an array of pointers to structs in C as
typedef struct{
int elem1;
char *elem2;
...
}example_t;
example_t *array[MAX_SIZE];
I did generic functions for add or delete pointers to ...
0
votes
1
answer
73
views
Trying to compile an example X11 program using gcc, failing to find "bitmaps/icon_bitmap"
I'm trying to compile an example program from chapter three of Volume One of the Xlib Programing manual.
I get an error saying that there is no such file or directory for #include "bitmaps/...
1
vote
1
answer
97
views
Ambiguous conversion warning: should I care?
This question can be considered probably theoretical as I don't see why I would have such design in real code.
I've got two classes with some conversion operators:
class B;
class A {
public:
A()...
5
votes
2
answers
188
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 ...
4
votes
1
answer
285
views
GCC bogus "may be used uninitialized " warning starting with version 11
In our codebase we have code that boils down to the following (trying to use dynamic stack allocation instead of heap allocation):
#include <memory>
#include <alloca.h>
void f(long long ...
3
votes
2
answers
118
views
How to leverage the [*]printf format type specification warnings?
As we all know and love (or hate), GCC has the capability of issuing warnings when you attempt to use the printf() family of functions with mismatched type specifications. In our code, we have a ...
0
votes
0
answers
587
views
Unexpected dangling-reference warning with gcc 13, how to avoid it? [duplicate]
The following c++ code gives me a Wdangling-reference warning with gcc 13/14 when I compile with -Wall -Wextra.
# include <iostream>
std::string create_default_x() noexcept
{
std::string ...
-1
votes
1
answer
157
views
dangerous relocation warning by gcc
i have a copy_object function which basicly just makes a copy of any object given a pointer to it and its size and i use it in a library i made
here is the function
/// @brief dynamically allocates a ...
9
votes
2
answers
2k
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 &...
0
votes
1
answer
287
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
...
2
votes
2
answers
707
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 ...
1
vote
3
answers
161
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 ...
3
votes
1
answer
174
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.
#...
1
vote
0
answers
87
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 ...
-5
votes
3
answers
264
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 ...
0
votes
1
answer
277
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",...
3
votes
1
answer
531
views
Is g++ -Wdangling-reference warning justified in this case?
Compiling my code with gcc 13.2 and -Wdangling-reference I was surprised that in this simple scenario (godbolt):
#include <vector>
#include <string>
std::string& add_variable(std::...
1
vote
2
answers
212
views
Incompatible pointer type assignment for double pointer to constant double pointer
I have the following code:
typedef struct S1 S1_t;
struct S1
{
uint8_t *ptr1;
uint8_t **ptr2;
};
void get_ptr1(const S1_t *s1, uint8_t const **ptr1)
{
*ptr1= s1->ptr1;
}
void get_ptr2(const ...
0
votes
0
answers
118
views
can't run simple code in C language in visual studio code
I've got the problem for the C language still I can't run my code and see the output
after installing gcc and the code runner extension still, I can't run my simple code in Visual Studio code
my code ...
1
vote
3
answers
2k
views
Getting incompatible pointer type warning because the return of the function is not void* but a struct pointer
This warning seems to not be necessary.
In my code, I have a function pointer type
(void*)(*function_pointer)(void* data)
and some functions require function pointers of this type as a parameter, ...
0
votes
2
answers
133
views
gcc doesn't detect array out of bounds for inline function
extern void myprint(unsigned char *);
static inline void
myfunc(unsigned char *buf)
{
for (unsigned int i = 0; i < 20; i++) {
buf[i] = i;
}
}
int
main(void)
{
unsigned char ...
1
vote
2
answers
213
views
-Woverloaded-virtual with default shallow copy operator
This warning is issued by the G++ compiler starting from GCC-13.
Clang++ 17 is happy with this code.
MSCV 19 produces the similar warning
(39): warning C4263: 'Derived &Derived::operator =(const ...
1
vote
1
answer
213
views
esp32-opencv-master flann: error: insn does not satisfy its constraints:
I'm following this repository text to be able to use openCV on a ESP32-CAM. I am able to make it work with the default libraries (imgcodecs, imgproc & core), but when trying to add calib3d, I get ...