undefined-behavior
Namespace Aliasing in C++
It is widely known that adding declarations/definitions to namespace std results in undefined behavior. The only exception to this rule is for template specializations.[详细]
2023-01-05 02:02 分类:问答Why in Ruby, a || 1 will throw an error when `a` is undefined, but a = a || 1 will not?
When a is undefined, then a || 1 will throw an error, but a = a || 1 will not.Isn开发者_JAVA技巧\'t that a little bit inconsistent?[详细]
2023-01-02 16:41 分类:问答Why did this code still work?
Some old code that I just came across: MLIST * new_mlist_link() { MLIST *new_link = (MLIST * ) malloc(sizeof(MLIST));[详细]
2022-12-29 01:56 分类:问答Is undefined behavior worth it?
Many bad things happened and continue to happen (or not, who knows, anything can happen) due to undefined behavior. I understand that this was introduced to leave some wiggle-room for compilers to opt[详细]
2022-12-29 00:14 分类:问答Why exactly is calling the destructor for the second time undefined behavior in C++?
As mentioned in this answer simply calling the destructor for the second time is already undefined behavior 12.4/14(3.8).[详细]
2022-12-29 00:05 分类:问答Call a non member function on an instance before is constructed
I\'m writing a class, and this doubt came up. Is this undef. behaviour? On开发者_如何学JAVA the other hand, I\'m not sure its recommended, or if its a good practice. Is it one if I ensure no exception[详细]
2022-12-27 03:17 分类:问答Is it undefined behavior in the case of the private functions call in the initializer list?
Consider the following code: struct Calc { Calc(const Arg1 & arg1, const Arg2 & arg2, /* */ const ArgN & argn) :[详细]
2022-12-24 18:30 分类:问答When does invoking a member function on a null instance result in undefined behavior?
Consider the following code: #include <iostream> struct foo { // (a): void bar() { std::cout << \"gman was here\" << std::endl; }[详细]
2022-12-24 12:07 分类:问答string s; &s+1; Legal? UB?
Consider the following code: #include <cstdlib> #include <iostream> #include <string> #include <vector>[详细]
2022-12-22 12:59 分类:问答Undefined, unspecified and implementation-defined behavior
What is undefined behavior (UB) in C and C++?What about unspecified behavior and implementa开发者_如何学运维tion-defined behavior?What is the difference between them?Undefined behavior is one of those[详细]
2022-12-22 00:29 分类:问答