undefined-behavior
Is unsigned char a[4][5]; a[1][7]; undefined behavior?
One of the examples of undefined behavior from the C standard reads (J.2): — An array subscript is out of range, even if an object is apparently accessible with the[详细]
2023-01-17 14:52 分类:问答Signed right shift = strange result?
I was helping someone with their homework and ran into this strange issue. The problem is to write a function that reverses the order of bytes of a signed integer(That\'s how the function was specifie[详细]
2023-01-17 05:00 分类:问答Is the "struct hack" technically undefined behavior?
What I am asking about is the well known \"last member of a struct has variable length\" trick. It goes something like this:[详细]
2023-01-16 16:21 分类:问答Optimizing away a "while(1);" in C++0x
Updated, see below! I have heard and read that C++0x allows an compiler to print \"Hello\" for the following snippet[详细]
2023-01-13 06:30 分类:问答Can UB cause several single-threaded app runs to produce different outputs?
Is it possible for code that meets the following conditions to produce different outputs for each run for the same input?[详细]
2023-01-12 09:24 分类:问答Invalidating set of pointers through indirection
Consider the following program.It creates a set of pointer-to-ints, and uses a custom indrect_less comparator that sorts the set by the v开发者_开发问答alue of the pointed-to integer.Once this is done[详细]
2023-01-11 03:43 分类:问答Behavior of an expression: Defined or Undefined?
I have the following code int m[4]={1,2,3,4}, *y; y=m; *y = f(y++); // Expression A My friend told me that Expression A has a well defined behavior but I am not sure whether he is correct.[详细]
2023-01-08 12:29 分类:问答Does explicitly calling destructor result in Undefined Behavior here?
In my opinion, the following code (from some C++ question) should lead to UB, but the it seems it is not. Here is the code:[详细]
2023-01-08 06:40 分类:问答Undefined behaviour (?) in C with char arrays
when i try char bla[32] = \"foobar\"; int i; putchar(bla[i]); with strlen(bla)开发者_Python百科 < i < 32, bla[i] is always \\0. but isn\'t this in fact undefined behaviour, and should be avoi[详细]
2023-01-06 01:55 分类:问答Is this a self-assignment bug in ATL::CComVariant?
ATL::CComVariant has a handful of assignment operators. What I see in the implementation is that in assignment operators accepting LPCOLESTR, IUnknown* or IDispatch* the first action is to call Clear([详细]
2023-01-05 21:04 分类:问答