In C, suppose for a pointer p we do *p++ = 0. If p points to an int variable, is this defined behavior? You can do arithmetic resulting in pointing o ...
In C, suppose for a pointer p we do *p++ = 0. If p points to an int variable, is this defined behavior? You can do arithmetic resulting in pointing o ...
I wrote a function with an optional string parameter, but accidentally instead of defaulting it to "" I defaulted it to 0: I compiled without any w ...
The following code below runs without a seg fault when I switch the code to so I receive a seg fault and am forced to switch my node property da ...
During a codebase refactor I found code like this: void myFunction (std::map<int, int> my_map) { int linked_element; if (my_map[linked_ ...
Imagine the following definition. struct X { double a[8] {0.0}; double b[8] {0.0}; } int main() { X x; x.a[10] = 1.0; } Is the beh ...
When I was looking for the expression v[i++]=i; why it is to define the behavior, I suddenly saw an explanation because the expression exists between ...
Suppose, you want to create 16 bit, 32 bit, 64 bit "views" to a byte array, which behave just as if they were respectively typed arrays themselves. T ...
I've been using overloaded operators as demonstrated in the second answer from here: How to use C++11 enum class for flags ... example: ... And ...
If executing library code results in non-deterministic behavior from some unrelated code which otherwise behaves deterministically and as expected, is ...
I have the following code snippet: Calling _nhp_var_you->to_array_char->_nhp_this_anon(_nhp_var_you->to_array_char) should, and does, retu ...
Setup: My app uses a SwiftUI Map, essentially as Using this code, I can show the map modally without problems. Problem: If I out comment the .fr ...
Assuming X and Y are suitable types for such usage, is it UB to use std::start_lifetime_as<X> on an area of memory in one thread as one type and ...
Can I use a std::array<int, N> to alias parts of a int[] without invoking UB? https://en.cppreference.com/w/cpp/container/array "This container ...
An external API expects a pointer to an array of values (int as simple example here) plus a size. It is logically clearer to deal with the elements i ...
I want to obtain a raw pointer to an FFI-defined static, whose concrete type is opaque to Rust. This is what I currently have: use std::{ffi::c_void ...
In the 3.8 Object lifetime, there is the following section Before the lifetime of an object has started but after the storage which the object wil ...
I had this question while reading C++ Standard, but it basically just references C Standard, so I guess this question applies to both languages. From ...
I've recently read about type punning and strict aliasing in C. I believe the following attempt at type-punning violates the strict aliasing rule: ...
Reading ES.43: Avoid expressions with undefined order of evaluation, it states that the result of this expression is undefined. I'm assuming that's ...
I am trying to understand what optimization process causes the following code to produce an infinite loop when compiled with the -O3 optimization flag ...