_Imaginary_I and _Complex_I Qualifiers | r0

JeanHeyd Meneide <>

May 15th, 2021

Document: n2726
Previous Revisions: None
Audience: WG14
Proposal Category: Change Request
Target Audience: General Developers, Library Developers
Latest Revision: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20_Imaginary_I%20and%20_Complex_I%20Qualifiers.html

Abstract:

This paper fixes some strange qualifiers on imaginary and complex macro expressions leftover from C99.

1 Changelog

1.1 Revision 0

2 Introduction & Motivation

It was noted in discussion around the Typeof papers that _Complex_I and _Imaginary_I both are specifically stated to expand to expressions which yield a const r-value, which seems strangely specified. Considering almost no other macros are specified like this, I looked into the past a bit to see if there was any particular reason for the const-ness of the Macro. The archives failed to yield any particularly enlightening reasoning for why this constant, of all the constants, was marked as const. The constants were introduced in C99, and have always been const qualified. The C99 Rationale makes no mention of it being const, and only talks about float as if the macro was not const-qualified.

Because it may become possible to observe types in the (very near) future, we should remove the const qualification from these macro productions. Current analysis indicates that this should affect no code, as all current generic facilities perform l-value conversion and the type of these macros are expressions (r-values), and thusly cannot have their address taken directly to expose it.

3 Wording

The following wording is relative to N2596.

Remove const from 7.3.1 paragraph 4 and 5

4 …; the macro

     _Complex_I
expands to a constant expression of type const float _Complexfloat _Complex, with the value of the imaginary unit.

5 The macros

imaginary

and

_Imaginary_I
are defined if and only if the implementation supports imaginary types;210) if defined, they expand to _Imaginary and a constant expression of type const float _Imaginaryfloat _Imaginary with the value of the imaginary unit.

Remove const from G.6 paragraph 1

1

… are defined, respectively, as _Imaginary and a constant expression of type const float _Imaginaryfloat _Imaginary with the value of the imaginary unit.