Re: [SC22WG14.32341] alx-0051r0 - don't misuse reserved identifier 'exp'
From: Vincent Lefevre <hidden>
Date: 2025-07-24 19:12:24
On 2025-07-24 18:33:47 +0000, Joseph Myers wrote:
On Tue, 15 Jul 2025, Alejandro Colomar wrote:quoted
Rationale Since 'exp' is a library function, it is a reserved identifier, which should not be used as a variable / parameter name.It's only reserved with external linkage and file scope, and as a macro name. (It might still be less confusing to avoid usage in these other contexts.)
The important point is:
quoted
7.1.3p1 says All potentially reserved identifiers (...) that are provided by an implementation with an external definition are reserved for any use.It's not "potentially reserved", but indeed "any use" seems too broad in that wording compared to the wording for actually reserved identifiers, which is more specific depending on the precise nature of how the identifier is defined.
It is not too broad. A compiler may define the identifier as
a builtin. For instance... GCC! The following program fails
to compile (note that I do not even include <math.h>):
static int exp (void)
{
return 1;
}
int foo (void)
{
return exp ();
}
tst.c:1:12: warning: conflicting types for built-in function ‘exp’; expected ‘double(double)’ [-Wbuiltin-declaration-mismatch]
1 | static int exp (void)
| ^~~
tst.c:1:1: note: ‘exp’ is declared in header ‘<math.h>’
+++ |+#include <math.h>
1 | static int exp (void)
--
Vincent Lefèvre [off-list ref] - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)