a.ha.cb.cWhy the compiler or linker is not complaining about two extern declarations with different type and same identifier (x), and they are silently linked together?
I have a problem understanding what can and cannot be done using unions with GCC. I read the questions (in particular here and here) about it but they focus the C++ standard, I feel there's a mismatch between the C++ standard and the practice (the commonly used compilers).
Would a large amount of stack space required by a function prevent it from being inlined? Such as if I had a 10k automatic buffer on the stack, would that make the function less likely to be inlined?
When I compile the following simple recursion code with g++, the assembly code simply returns i, as if g++ can do some algebra tricks as humans can.
Consider the following code:I want the compiler to raise a warning when passing const char* instead of bool as a parameter to function foo.
I was self-studying CSAPP and got a strange result when I ran into a strange issue during the run of a assertion test.
consider following code:I want compiler raise warning, when passing const char* instead of bool as parameter to function foo. But GCC implicitly converts it. I tried -Wall, -Wextra, -Wpedantic, nothing works. Is there any flag that, could catch such implicit conversion (invalid parameter type)?
I am using Ubuntu 16.04.5 with gcc version 5.4.0I was playing with sizeof() operator, wrote the code below:
Why doesn't the following code compile?The compile command:The output:I'm using gcc6.4.The restrictions on what can be used in a constant expression are defined mostly as a list of negatives. There's a bunch of things you're not allowed to evaluate ([expr.const]/2 in C++14) and certain things that values have to result...
Could you please explain why this code doesn't compile?The compile command:I've tried gcc5.4 and gcc6.4. The error: