Is alignof(T*) is the same value for all possible types T? What about sizeof(T*)?
Please answer based on what is allowed/specified by the standard and not what is the current situation in different compilers.
Is alignof(T*) is the same for all possible types? What about sizeof(T*)?
209 Views Asked by Koosha At
1
There are 1 best solutions below
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in POINTERS
- What does: "char *argv[]" mean?
- Memory allocated for pointer to string literals
- change the value of double pointer with indirection(dereference) operator cause segmentation fault
- Unexpected result when assigning and printing pointer value of two-dimensional array with its name
- The character array data changes when I use it inside for loop. I do not understand why does it change, the data ")" becomes "("
- char * gives garbage value when pointing to a variable of a function in C
- What is correct way to copy struct instance with fields in Go?
- PHP FFI: How to pass PHP class object to C++
- How to make a single slider with three pointer
- rac dangling pointer crash。
- Is casting "pointer to array of type" to "pointer to type" defined?
- C++: How to implement a pointer to another class as a member?
- What is the purpose of (int *) p here?
- Initialize a structure pointer to NULL, then try to change its members
- Could an unitialized pointer be a NULL pointer?
Related Questions in LANGUAGE-LAWYER
- Can std::bit_cast be applied to an empty object?
- Static data member of template class type: constexpr vs. const constinit
- What was the problem with std::is_callable?
- Clang fails with "function with deduced return type cannot be used before it is defined", while GCC works
- Can a tentative definition use the storage class specifier _Thread_local?
- operator delete after both operator new and placement new?
- Is casting "pointer to array of type" to "pointer to type" defined?
- Are there uses of std::forward, where the argument is not a variable name?
- Why does C++ allow making a reference to a variable that goes out of scope?
- Deadlock on static-initialized jthread calling std::stacktrace_entry::description
- Is it legal to zero empty C++ classes in the constructor and inherit from them?
- Are there any specific types or values for which type-punning produces identical behavior in all Standard-conforming C implementations?
- Function pointer compatibility between single pointer and empty parameter lists
- In C++ can you use one empty type as storage for another?
- When is it safe to use [[no_unique_address]] in C++?
Related Questions in SIZEOF
- Does sizeof result depends on the declaration of the string?
- Size of a structure considering padding with strings and int as element
- I am studying type modifiers in c and when i am facing some problem
- C++ find size of the short* array
- sizeof a really big array
- Why is malloc allocated array shows less size than static allocated array
- What is the correct output of sizeof("string")?
- sizeof(char[]) in a struct member with no size specified
- How is a C program able to determine the size of an array?
- Struct Padding Optimization in C
- Inconsistent sizeof Behavior:
- Memory allocation for pointer to an array in c?
- Inconsitent behavior of `Marshal.SizeOf<T>()` and `Marshal.SizeOf<T>(T structure)`
- Evaluate the size in bytes of something in C++
- How to control the size of a class to be a multiple of the size of a member?
Related Questions in ALIGNOF
- Writing an alignof(T) method in C#?
- Why using alignof on non-typed types is valid?
- C2x: if _Alignof(array type) yields the alignment of the element type, then will it be useful to permit _Alignof(incomplete array type)?
- _Alignof with operand of variable length array type: is there a contradiction in the standard?
- Effective type in packed raw data
- error: storage class may not be specified here when using __align() in MDK ARM uVision v5 ARM Compiler 5
- The sizeof and _Alignof value of a structure
- Is alignof(T*) is the same for all possible types? What about sizeof(T*)?
- Why is alignof(max_align_t) 16?
- Does `T` always have the same size and alignment as `std::aligned_storage<sizeof(T), alignof(T)>`
- Is it always the case that sizeof(T) >= alignof(T) for all object types T?
- How to tell the maximum data alignment requirement in C++
- Alignment and size of C++ primitive types
- When did Clang gain support for C++11's alignof keyword?
- `std::alignment_of` versus `alignof`
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The standard doesn't say much about sizes and alignments of pointers, and thus they are not strictly restricted by the language.
Conversion from one valid pointer to function into another and back is guaranteed to produce the original value. As such, there must be the same minimum number of values that must be representable that is the maximum number of valid addresses for any given pointer to function type which gives lower bound to the size of all pointer to function types.
Conversions between object types have a similar guarantee, which however only applies when the original pointed type has stricter or equal alignment requirement. As a consequence, object pointers to highly aligned types require fewer representable values. If the alignment is high enough, then the type could in theory be smaller.
On systems where conversion between pointer to void and pointer to function is allowed (which is conditionally supported), the minimum number of representable values of pointers to functions and pointers to void must be the same.
But even so, some pointer types could be larger than the number of representable values it needs. Those extra bits would simply necessarily be unused. This would not be very practical.