undefined-behavior
Where is the undefined behavior when using const_cast<>?
If I do: const char* const_str = \"Some string\"; char* str = const_cast<char*>(const_str); // (1)[详细]
2023-02-22 08:55 分类:问答expression: deque iterator not incrementable (special case - i can't figure it out)
I have something like deq.push_back(object) which works fine in a source file but not in another one - if I try the same operation there I get the runtime error in the title. How can it be possible? d[详细]
2023-02-20 07:47 分类:问答Comma operator and void expression
I came across this code snippet 1 int return_printChar1() { // code // oops! no return statement } int return_printChar2()[详细]
2023-02-19 16:16 分类:问答Is this undefined behavior in C/C++
int foo(int c){ return c; } int main(void){ int a=5,c; c = foo(--a) + a; } Will it invoke undefined behavior in C/C++? I think no it won\'t.[详细]
2023-02-19 02:07 分类:问答Unexpected output
#include <iostream> int main() { const int i=10; int *p =(int *) &i; *p = 5; cout<<&i<<\" \"<&开发者_StackOverflowlt;p<<\"\\n\";[详细]
2023-02-16 23:31 分类:问答Why does XOR swap with integers trigger a warning?
I typed the following program: #include <stdio.h> int main(void) { int a = 3; int b = 42; printf(\"a = %d\\nb = %d\\n\", a, b);[详细]
2023-02-14 05:12 分类:问答Undefined behaviour in (X)HTML?
Is there such a thing as undefined behaviour in (X)HTML? I have wondered this after playing around with the <button> tag, which allows HTML to be rendered as button. Nothing new so far...[详细]
2023-02-11 20:19 分类:问答How do languages handle side effects of compound operators?
Assume such situation: int a = (--t)*(t-2); int b 开发者_JAVA百科= (t/=a)+t; In C and C++ this is undefined behaviour, as described here: Undefined behavior and sequence points[详细]
2023-02-11 11:37 分类:问答Weird cout behavior in C++
I am getting some weird behavior when using cout in my programm, which is similar to the following: ...[详细]
2023-02-11 06:30 分类:问答sizeof(""+0) != sizeof(char *) Bug or undefined behaviour?
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\\n",sizeof "",sizeof(""+0),sizeof(char *));[详细]
2023-02-07 17:29 分类:问答