This is the mail archive of the
mailing list for the GCC project.
[C++11] Reclaiming fixed-point suffixes for user-defined literals.
- From: 3dw4rd at verizon dot net
- To: gcc at gcc dot gnu dot org
- Date: Fri, 04 Nov 2011 14:35:51 -0500 (CDT)
- Subject: [C++11] Reclaiming fixed-point suffixes for user-defined literals.
Now that C++11 user-defined literals are in trunk I was thinking about reclaiming some of the numeric suffixes that are currently recognized by gcc in the preprocessor. The C++11 spec stipulates that any suffix that is recognized by the implementation is not allowable as a user-defined literal suffix in c++. This prevents C++ from hijacking 123LL, 1.234L, etc. On the other hand, there are several numeric literal suffixes that are recognized and used as gnu extensions.
One class of suffixes stands out in this connection: fixed-point literals. These end in 'k' or 'r' and can optionally be unsigned by starting with 'u' and optionally have a size 'h', 'l', 'll'. The difference for these suffixes is that fixed-point literals are explicitly rejected by the c++ front end. Attempts to use such literals:
int i= 1.23k;
results in 'error: fixed-point types not supported in C++'.
So I ask the question: Should I make a simple change to libcpp to allow fixed-point literal suffixes to pass to the user-defined literal code in c++11 mode?
P.S. There are other suffixes that might be reclaimed as well such as 'i', 'I', 'j', 'J' for complex integral or floating point imaginary numbers and others. These might be more difficult or impossible to reclaim for C++11 because these might be allowed and used in gnu-C++ and it might break existing code.