mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
enrich comment
Added description and URL about nested flexible array member.
This commit is contained in:
parent
4cc501bcfd
commit
c6c241e49c
Notes:
git
2020-09-25 11:39:03 +09:00
1 changed files with 13 additions and 4 deletions
|
@ -112,10 +112,19 @@ struct rbimpl_alignof {
|
|||
# define RBIMPL_ALIGNOF __alignof
|
||||
|
||||
#else
|
||||
# /* :BEWARE: It is an undefined behaviour to define a struct/union inside of
|
||||
# * `offsetof()`! This section is the last resort. If your compiler somehow
|
||||
# * supports querying alignment of a type please add your own definition of
|
||||
# * `RBIMPL_ALIGNOF` instead. */
|
||||
# /* :BEWARE: This is the last resort. If your compiler somehow supports
|
||||
# * querying the alignment of a type, you definitely should use that instead.
|
||||
# * There are 2 known pitfalls for this fallback implementation:
|
||||
# *
|
||||
# * Fitst, it is either an undefined behaviour (C) or an explicit error (C++)
|
||||
# * to define a struct inside of `offsetof`. C compilers tend to accept such
|
||||
# * things, but AFAIK C++ has no room to allow.
|
||||
# *
|
||||
# * Second, there exist T such that `struct { char _; T t; }` is invalid. A
|
||||
# * known example is when T is a struct with a flexible array member. Such
|
||||
# * struct cannot be enclosed into another one.
|
||||
# */
|
||||
# /* see: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2083.htm */
|
||||
# /* see: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm */
|
||||
# define RBIMPL_ALIGNOF(T) offsetof(struct { char _; T t; }, t)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue