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:
I wrote this simple assembly code, ran it and looked at the memory location using GDB:It's adding 5 to 6 directly in memory and according to GDB it worked. So this is performing math operations directly in memory instead of CPU registers.
I wrote this simple assembly code, ran it and looked at the memory location using GDB:It's adding 5 to 6 directly in memory and according to GDB it worked. Now writing the same thing in C and compiling it to assembly turns out like this: