On 2/1/21 1:46 PM, Ed Smith-Rowland wrote:
On 2/1/21 10:33 AM, Jason Merrill wrote:
On 1/30/21 6:22 PM, Ed Smith-Rowland wrote:
On 1/27/21 3:32 PM, Jakub Jelinek wrote:
On Sun, Oct 21, 2018 at 04:39:30PM -0400, Ed Smith-Rowland wrote:
This patch implements C++2a proposal P0330R2 Literal Suffixes for
ptrdiff_t
and size_t*. It's not official yet but looks very likely to pass.
It is
incomplete because I'm looking for some opinions. 9We also might
wait 'till
it actually passes).
This paper takes the direction of a language change rather than a
library
change through C++11 literal operators. This was after feedback on
that
paper after a few iterations.
As coded in this patch, integer suffixes involving 'z' are errors
in C and
warnings for C++ <= 17 (in addition to the usual warning about
implementation suffixes shadowing user-defined ones).
OTOH, the 'z' suffix is not currently legal - it can't break
currently-correct code in any C/C++ dialect. furthermore, I
suspect the
language direction was chosen to accommodate a similar addition to
C20.
I'm thinking of making this feature available as an extension to
all of
C/C++ perhaps with appropriate pedwarn.
GCC now supports -std=c++2b and -std=gnu++2b, are you going to
update your
patch against it (and change for z/Z standing for ssize_t rather than
ptrdiff_t), plus incorporate the feedback from Joseph and Jason?
Jakub
Here is a rebased patch that is a bit leaner than the original.
Since I chose to be conservative in applying this just to C++23 I'm
not adding this to C or t earlier versions of C++ as extensions. We
can add that if people really want, maybe in stage 1.
The compat warning for C++ < 23 is not optional. since the suffixes
are not preceded by '-' I don't hav much sympathy if people tried to
make a literal 'z' operator. Which is the only reason I can see for a
warning suppression.
+ /* itk refers to fundamental types not aliased size types. */
+ if (flags & CPP_N_UNSIGNED)
+ type = size_type_node;
+ else
+ type = ptrdiff_type_node;
I thought size_type_node and ptrdiff_type_node were sort of fundamental
the the others derived:
Yes, but the final proposal specifies a suffix for signed size_t, not
ptrdiff_t.
ssize_t:
signed_size_type_node = c_common_signed_type (size_type_node);
Ah, I wasn't aware of signed_size_type_node, that's better than my
suggestion of calling c_common_signed_type again.
Jason