type-punning
C type punning question
How do I make the below function generic for uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t and float_t?[详细]
2023-03-13 13:58 分类:问答Does a simple cast to perform a raw copy of a variable break strict aliasing?
I\'ve been reading about strict aliasing quite a lot lately. The C/C++ standards say that the following code is invalid (undefined behavior to be correct), since the compiler might have the value of a[详细]
2023-02-12 00:49 分类:问答Is reinterpret_cast mostly useless?
I\'ve read various previous questions about the use of reinterpret_cast, and I\'ve also read the relevant wording in the C++ standard.Essentially, what it comes down to is that the result of a pointer[详细]
2023-02-12 00:06 分类:问答Convert pointer to loop option in C#
How would I convert this into 开发者_JAVA百科a loop and not to use the pointer. byte[] InputBuffer = new byte[8];[详细]
2023-02-08 10:35 分类:问答float bits and strict aliasing
I am trying to extract the bits from a float without invoking undefined behavior. Here is my first attempt:[详细]
2023-01-28 01:59 分类:问答Placement-new vs gcc 4.4.3 strict-aliasing rules
I\'ve got some code that I\'ve been using successfully for some years to implement a \"variant-type object\"; that is, a C++ object that can hold a values of various types, but only uses (approximatel[详细]
2023-01-26 09:00 分类:问答Strict pointer aliasing: any solution for a specific problem?
I have a problem caused by breaking strict pointer alia开发者_开发百科sing rule.I have a type T that comes from a template and some integral type Int of the same size (as with sizeof).My code essentia[详细]
2023-01-02 04:41 分类:问答Compile time float packing/punning
I\'m writing C for the PIC32MX, compiled with Microchip\'s PIC32 C compiler (based on GCC 3.4). Added The standard I\'m following is GNU99 (C99 with GNU extensions, compiler flag -std=gnu99)[详细]
2023-01-01 12:10 分类:问答Purpose of Unions in C and C++
I have used unions earlier comfortably; today I was alarmed when I read this post and came to know that this code[详细]
2022-12-20 17:46 分类:问答Java: Using type punning on primitive arrays?
I need to be able to convert byte arrays to/from other primitive type arrays, but instead of casting, I need type punning. Correct term for raw copy without casting?[详细]
2022-12-19 21:26 分类:问答