This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: proposal to make SIZE_TYPE more flexible
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: <richard dot guenther at gmail dot com>, <gcc at gcc dot gnu dot org>
- Date: Thu, 9 Jan 2014 02:31:06 +0000
- Subject: Re: proposal to make SIZE_TYPE more flexible
- Authentication-results: sourceware.org; auth=none
- References: <201310300422 dot r9U4M6Mx002568 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1311212258320 dot 26755 at digraph dot polyomino dot org dot uk> <201311220828 dot rAM8Ss0q011135 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1311221231510 dot 5029 at digraph dot polyomino dot org dot uk> <201311221933 dot rAMJXDUt031382 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1311222046100 dot 12354 at digraph dot polyomino dot org dot uk> <201311222118 dot rAMLIxag003002 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1311230039030 dot 12354 at digraph dot polyomino dot org dot uk> <201312100334 dot rBA3YwMq017441 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1312101709200 dot 15324 at digraph dot polyomino dot org dot uk> <201312201947 dot rBKJlgKS003922 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1312202151510 dot 29339 at digraph dot polyomino dot org dot uk> <201312202159 dot rBKLxmIZ007173 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1312202215280 dot 29339 at digraph dot polyomino dot org dot uk> <201312202240 dot rBKMeVfM008400 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1312210100330 dot 29339 at digraph dot polyomino dot org dot uk > <201401090031 dot s090VGm9003938 at greed dot delorie dot com>
On Wed, 8 Jan 2014, DJ Delorie wrote:
> > I think a patch is more useful once believe feature-complete, which
> > means replacing the __int128 support with the new mechanism.
>
> One of the side-effects of taking out the existing __int128 support is
> that __int128 isn't in the integer_type_kind list, so isn't a type
> that is usable for constants. This breaks int128-4.C, which assumes a
> 128-bit integer constant. If I add generic support for intN types in
I don't see constants in that test.
It's not possible to write constants of type __int128 anyway. It *is*
possible to build them up using expressions casting narrower constants to
__int128. If you write a constant with a large value (with or without a
suffix) that won't fit in target intmax_t / uintmax_t (or target long /
unsigned long for C90), then you should get a pedwarn (and some larger
type, maybe widest_integer_literal_type_node /
widest_unsigned_literal_type_node, will be used if available).
> i_t_k[], then we'll get (for example) 20-bit constants, which might
> not be what we want. The only other option is to special-case
> __int128 if we find it in the __intN list.
Integer constant types should be taken from the int / long / long long
(and unsigned variants) list. If a constant can't fit in any type ISO C
allows for it, then it's reasonable to go on the extended types wider than
long long, in increasing order of size, but __int20 is never relevant for
constants as it's always narrower than long.
> Thoughts?
It's desirable anyway to have a way of representing what might be a
standard type from integer_type_kind, or an extended type, given that it
would be good for macros such as SIZE_TYPE to evaluate to enumerated
values not magic strings. Maybe a reserved space of itk_* values just
like reserving RID_* values?
> Also, I noted a few tests check for the int128-specific error message
> when the type is not supported, but as per our previous discussion,
> the __int128 keyword just doesn't exist if the type isn't supported.
> Do we need to discern between "not supported with these options" and
> "not supported ever" ?
I don't think there's a need to distinguish, although I don't think it
would be particularly harmful to have an __int128 keyword present without
a corresponding type for targets not supporting __int128, if that helps
diagnostics, as long as nothing else special-cases __int128.
(Draft TS 18661-3 has the interesting peculiarity that the keywords
_FloatN for N = 16, 32, 64 or >= 128 and a multiple of 32, _DecimalN for N
>= 32 and a multiple of 32, and _Float32x, _Float64x, _Float128x,
_Decimal64x, _Decimal128x always exist as keywords whether or not the
corresponding types are supported. Implementing that would I suppose
require special checks to handle arbitrary _FloatN and _DecimalN (for
valid N) as keywords - an infinite number of keywords - much as we handle
_Imaginary as a keyword without otherwise implementing it.)
--
Joseph S. Myers
joseph@codesourcery.com