On 3/7/25 02:21, Jakub Jelinek wrote:
Hi!
This attempts to clarify Complex literal suffixes in the documentation.
Thanks for helping straighten this out!
--- gcc/doc/extend.texi.jj 2025-03-05 06:39:50.263296970 +0100
+++ gcc/doc/extend.texi 2025-03-07 10:00:25.816829046 +0100
@@ -990,19 +990,23 @@ have real and imaginary parts of type @c
likely to be useful, but it shows that the set of complex types is
complete.
-To write a constant with a complex data type, use the suffix @samp{i} or
-@samp{j} (either one; they are equivalent). For example, @code{2.5fi}
-has type @code{_Complex float} and @code{3i} has type
+To write a constant with a complex data type, use the suffix @samp{i},
+@samp{I}, @samp{j} or @samp{J} (any one; they are equivalent). For
+example, @code{2.5fi} has type @code{_Complex float} and @code{3i} has type
@code{_Complex int}. Such a constant always has a pure imaginary
value, but you can form any complex value you like by adding one to a
-real constant. This is a GNU extension; if you have an ISO C99
-conforming C library (such as the GNU C Library), and want to construct complex
-constants of floating type, you should include @code{<complex.h>} and
-use the macros @code{I} or @code{_Complex_I} instead.
+real constant. This is part of ISO C2Y and for older C revisions
+a GNU extension. For C++ if @code{-fext-numeric-literals} option is
+enabled, it is also a GNU extension, otherwise it is handled like any
+other C++ user-defined literal. If you have an ISO C99 conforming C library
I think it would be better to move the sentence about C++ to the
following paragraph instead of inserting it into the middle of a
discussion about C2Y.
+(such as the GNU C Library), and want to construct complex
+constants of floating type before ISO C2Y, you should include
s/before ISO C2Y/when using standard versions before ISO C2Y/
+@code{<complex.h>} and use the macros @code{I} or @code{_Complex_I} instead.
The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
that includes the @samp{<complex>} header cannot use @samp{i} for the
-GNU extension. The @samp{j} suffix still has the GNU meaning.
+GNU extension. The @samp{I}, @samp{j} or @samp{J} suffixes still have
+the GNU meaning.
GCC handles both implicit and explicit casts between the
@code{_Complex} types with different scalar base types by casting both
OK with those changes.
-Sandra