public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about non-POD class type
       [not found] <SN6PR01MB4958FB2103C8EA600AF25147F7509@SN6PR01MB4958.prod.exchangelabs.com>
@ 2021-05-14  8:35 ` Feng Xue OS
  0 siblings, 0 replies; only message in thread
From: Feng Xue OS @ 2021-05-14  8:35 UTC (permalink / raw)
  To: gcc

Sorry, sent to wrong mail list.

________________________________________
From: Feng Xue OS
Sent: Friday, May 14, 2021 4:30 PM
To: gcc-patches@gcc.gnu.org
Subject: Question about non-POD class type

For an instance of a non-POD class, can I always assume that any
operation on it should be type-safe, any wrong or even trick code
to violate this is UB in C++ spec? For example, here are some ways:

 union {
    Type1  *p1;
    Type2  *p2;
};

or

union {
    Type1 t1;
    Type2 t2;
};

or

void *p = Type1 *p1;
Type2 *p2 = p;
p2->xxx;

Feng

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-14  8:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <SN6PR01MB4958FB2103C8EA600AF25147F7509@SN6PR01MB4958.prod.exchangelabs.com>
2021-05-14  8:35 ` Question about non-POD class type Feng Xue OS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).