* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
@ 2022-07-24 21:28 ` sam at gentoo dot org
2022-07-24 21:34 ` ldv at sourceware dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sam at gentoo dot org @ 2022-07-24 21:28 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
2022-07-24 21:28 ` [Bug libc/29399] " sam at gentoo dot org
@ 2022-07-24 21:34 ` ldv at sourceware dot org
2022-07-24 22:06 ` pavel.morozkin at gmail dot com
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ldv at sourceware dot org @ 2022-07-24 21:34 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
Dmitry V. Levin <ldv at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |ldv at sourceware dot org
URL| |https://www.gnu.org/softwar
| |e/libc/manual/html_node/Res
| |erved-Names.html
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Dmitry V. Levin <ldv at sourceware dot org> ---
"reserved names include all external identifiers (global functions and
variables) that begin with an underscore (‘_’) [...]. This is so that the
library and header files can define functions, variables, and macros for
internal purposes without risk of conflict with names in user programs."
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
2022-07-24 21:28 ` [Bug libc/29399] " sam at gentoo dot org
2022-07-24 21:34 ` ldv at sourceware dot org
@ 2022-07-24 22:06 ` pavel.morozkin at gmail dot com
2022-07-24 22:09 ` schwab@linux-m68k.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pavel.morozkin at gmail dot com @ 2022-07-24 22:06 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #2 from Pavel M <pavel.morozkin at gmail dot com> ---
Why it was resolved as INVALID? Per C identifier with block scope that begins
with an underscore, followed by a lowercase letter (e.g. _setjmp) is not
reserved. So the user may use _setjmp for its own purposes. Please reconsider.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (2 preceding siblings ...)
2022-07-24 22:06 ` pavel.morozkin at gmail dot com
@ 2022-07-24 22:09 ` schwab@linux-m68k.org
2022-07-28 16:33 ` pavel.morozkin at gmail dot com
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: schwab@linux-m68k.org @ 2022-07-24 22:09 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-07-24
Status|RESOLVED |REOPENED
Ever confirmed|0 |1
Resolution|INVALID |---
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
The name is only reserved in file scope.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (3 preceding siblings ...)
2022-07-24 22:09 ` schwab@linux-m68k.org
@ 2022-07-28 16:33 ` pavel.morozkin at gmail dot com
2022-07-28 16:50 ` fweimer at redhat dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pavel.morozkin at gmail dot com @ 2022-07-28 16:33 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #4 from Pavel M <pavel.morozkin at gmail dot com> ---
Another example:
#define _setjmp 0
#include <setjmp.h>
void f(void)
{
jmp_buf x;
setjmp(x);
}
<source>:1:17: error: expected identifier or '(' before numeric constant
1 | #define _setjmp 0
| ^
<source>: In function 'f':
<source>:1:17: error: called object is not a function or function pointer
1 | #define _setjmp 0
| ^
/usr/include/setjmp.h:62:25: note: in expansion of macro '_setjmp'
62 | #define setjmp(env) _setjmp (env)
| ^~~~~~~
Compiler returned: 1
Per C all identifiers that begin with an underscore, followed by a lowercase
letter AND used as macros are non-reserved.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (4 preceding siblings ...)
2022-07-28 16:33 ` pavel.morozkin at gmail dot com
@ 2022-07-28 16:50 ` fweimer at redhat dot com
2022-07-28 19:38 ` zackw at panix dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: fweimer at redhat dot com @ 2022-07-28 16:50 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
--- Comment #5 from Florian Weimer <fweimer at redhat dot com> ---
I think C11 is ambiguous whether macros like _setjmp have file scope or not and
are thus reserved or not. It really only makes sense to treat macros as having
file scope for the purpose of identifier reserved-ness, so the example in
comment 4 is invalid (but the one in comment 0 is valid).
Has the scope of macros been clarified in later versions of the C standard?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (5 preceding siblings ...)
2022-07-28 16:50 ` fweimer at redhat dot com
@ 2022-07-28 19:38 ` zackw at panix dot com
2022-07-29 6:53 ` pavel.morozkin at gmail dot com
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: zackw at panix dot com @ 2022-07-28 19:38 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
Zack Weinberg <zackw at panix dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |zackw at panix dot com
--- Comment #6 from Zack Weinberg <zackw at panix dot com> ---
I don't think the standard is ambiguous at all. Its wording could be improved,
but there's only one interpretation that makes sense.
Since at least C11, section 7.1.3p2 reads in part
> If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), **or defines a reserved identifier as a macro name**, the behavior is undefined.
The clause set off by double asterisks doesn't make any sense unless "a
reserved identifier" is understood broadly: if the program defines an
identifier that is reserved *in any context* as macro name, the behavior is
undefined.
To put it another way, I believe the intent of this sentence is that any
identifier that is reserved in any phase-7 context is also, unconditionally,
reserved for use as a macro name.
---
The program in comment 4 defines a reserved identifier as a macro name, and is
therefore invalid. The program in comment 0, on the other hand, doesn't define
any macros; it defines a *local variable*, using a name that is reserved for
use by the implementation *only* at file scope. This clashes with setjmp.h
assuming that the `_setjmp` in the expansion of the `setjmp` macro will refer
to a global symbol. I think this *is* a bug in glibc's setjmp.h. The thing
it's doing with macros should be done with __REDIRECT instead.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (6 preceding siblings ...)
2022-07-28 19:38 ` zackw at panix dot com
@ 2022-07-29 6:53 ` pavel.morozkin at gmail dot com
2022-07-29 12:25 ` fweimer at redhat dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pavel.morozkin at gmail dot com @ 2022-07-29 6:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #7 from Pavel M <pavel.morozkin at gmail dot com> ---
Macros don't have file scope. The scope of macro definitions is defined in C11,
6.10.3.5.
The program in comment 4 defines a non-reserved identifier as a macro name, and
is therefore valid.
P.J. Plauger, Standard C Library Name Space Control, JCLT, 1(4), page 251:
> Remember that the user can write macros that begin with an underscore, followed by a lowercase letter.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (7 preceding siblings ...)
2022-07-29 6:53 ` pavel.morozkin at gmail dot com
@ 2022-07-29 12:25 ` fweimer at redhat dot com
2022-07-29 14:03 ` pavel.morozkin at gmail dot com
2022-07-29 15:53 ` schwab@linux-m68k.org
10 siblings, 0 replies; 12+ messages in thread
From: fweimer at redhat dot com @ 2022-07-29 12:25 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #8 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to Zack Weinberg from comment #6)
> I don't think the standard is ambiguous at all. Its wording could be
> improved, but there's only one interpretation that makes sense.
>
> Since at least C11, section 7.1.3p2 reads in part
>
> > If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), **or defines a reserved identifier as a macro name**, the behavior is undefined.
>
> The clause set off by double asterisks doesn't make any sense unless "a
> reserved identifier" is understood broadly: if the program defines an
> identifier that is reserved *in any context* as macro name, the behavior is
> undefined.
On the other hand, 6.2.1p1 refuses to define scope for macro names and macro
parameters, so it's hard to see how the an “identifier with file scope” could
refer to a macro name.
I think 7.1.3 leaves something to be desired anyway because it makes it pretty
clear that this is valid:
#define tm_sec puts ("Hello, world!")
#include <time.h>
int
main (void)
{
tm_sec;
return 0;
}
But to implement that, we would have to use non-standard preprocessor features
(#pragma push_macro, #pragma pop_macro).
(Historically, structure fields had file scope (similar to some ML flavors),
but that hasn't been true for a long, long time.)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (8 preceding siblings ...)
2022-07-29 12:25 ` fweimer at redhat dot com
@ 2022-07-29 14:03 ` pavel.morozkin at gmail dot com
2022-07-29 15:53 ` schwab@linux-m68k.org
10 siblings, 0 replies; 12+ messages in thread
From: pavel.morozkin at gmail dot com @ 2022-07-29 14:03 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #9 from Pavel M <pavel.morozkin at gmail dot com> ---
The term "file scope" (6.2.1/4) is relevant only at translation phase 7. The
"preprocessing directives are executed, macro invocations are expanded" at
translation phase 4. At translation phase 4 there is no "identifier with file
scope" because there is no "file scope".
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libc/29399] Wrong definition of setjmp
2022-07-24 19:25 [Bug libc/29399] New: Wrong definition of setjmp pavel.morozkin at gmail dot com
` (9 preceding siblings ...)
2022-07-29 14:03 ` pavel.morozkin at gmail dot com
@ 2022-07-29 15:53 ` schwab@linux-m68k.org
10 siblings, 0 replies; 12+ messages in thread
From: schwab@linux-m68k.org @ 2022-07-29 15:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29399
--- Comment #10 from Andreas Schwab <schwab@linux-m68k.org> ---
1.7.3#2 does not mention any context for the identifiers that may not be
defined as macros.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 12+ messages in thread