Tom Tromey <t...@tromey.com> writes: >>>>>> "Richard" == Richard Sandiford via Gcc-patches <gcc-patches@gcc.gnu.org> >>>>>> writes: > > Richard> +// A class that stores a choice "A or B", where A has type T1 * and > B has > Richard> +// type T2 *. Both T1 and T2 must have an alignment greater than > 1, since > Richard> +// the low bit is used to identify B over A. T1 and T2 can be the > same. > > It seems like the alignment requirement could be static_assert'd, which > would make using this class a bit safer.
Yeah, I wondered about doing that, but in principle there's nothing to stop people using the class for something like a char*, provided that the start is suitably aligned. So having gcc_checking_assert is a compromise: it only provides run-time checking rather than compile-time checking, but it doesn't place any artificial limits on how the class can be used. Thanks, Richard