From owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org  Wed Sep  2 11:52:47 2026
Return-Path: <owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org>
X-Original-To: sc22wg14-domo2
Delivered-To: sc22wg14-domo2@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id D0127356E1E; Wed,  2 Sep 2026 11:52:47 +0200 (CEST)
Delivered-To: sc22wg14@open-std.org
Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104])
	by www.open-std.org (Postfix) with ESMTP id 80287356CE7
	for <sc22wg14@open-std.org>; Wed,  2 Sep 2026 11:52:46 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
  d=inria.fr; s=dc;
  h=date:from:to:cc:subject:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=I/QvUzdnF66/ceRrCwgy0g7egnAl8dL4KkiGfslO/Og=;
  b=C83T1wzYj3mt1qXuxD+4FhW3hK/zSH+x44fCTSFYf7VFSJb2jXXLF7te
   /6SjqYsUGfhEQQMZ9sjz0CLTnKsEKeYH/h6LOkoo8SAg/+O8EDjy6pJbH
   QMEck5Ff/eeeEgcdsJj+bGSSLPPwcUfG5qY6WM5ocI9eu9c1qGI64NonD
   Y=;
X-CSE-ConnectionGUID: ov3Dr+yUQGCCUnd7pdO9BQ==
X-CSE-MsgGUID: qizy0fpbRkaz49hafUMxZQ==
Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=jens.gustedt@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr
X-IronPort-AV: E=Sophos;i="6.25,257,1779141600"; 
   d="scan'208";a="155684072"
Received: from lfbn-str-1-96-234.w92-140.abo.wanadoo.fr (HELO inria.fr) ([92.140.223.234])
  by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2026 11:52:47 +0200
Date: Wed, 2 Sep 2026 11:52:45 +0200
From: =?UTF-8?B?SuKCkeKCmeKCmw==?= Gustedt <jens.gustedt@inria.fr>
To: Joseph Myers <josmyers@redhat.com>
Cc: sc22wg14@open-std.org
Subject: Re: [SC22WG14.37787] New issue #1103: Contradictory requirements of
 linkage
Message-ID: <20260902115245.03e267fd@inria.fr>
In-Reply-To: <20260901202541.12454356E47@www.open-std.org>
References: <20260901202541.12454356E47@www.open-std.org>
Organization: inria.fr
X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu)
X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Sender: owner-sc22wg14@open-std.org
Precedence: bulk

Hello,

on Tue, 01 Sep 2026 20:25:35 +0000 you (Joseph Myers
<josmyers@redhat.com>) wrote:

> The following new C standard issue has been submitted.
>=20
> https://www.open-std.org/jtc1/sc22/wg14/issues/c23/issue1103.html
>=20
> ## Issue 1103: Contradictory requirements of linkage
>=20
> Authors: Jay Ghiron =20
> Date: 2026-09-01 =20
> Submitted against: C23 =20
> Status: Open
>=20
> Consider the second declaration in the following:
>=20
> ```c
> static int x;
> extern int x;
> ```
>=20
> > For an identifier declared with the storage-class specifier `extern`
> > in a scope in which a prior declaration of that identifier is
> > visible, if the prior declaration specifies internal or external
> > linkage, the linkage of the identifier at the later declaration is
> > the same as the linkage specified at the prior declaration.  If no
> > prior declaration is visible, or if the prior declaration specifies
> > no linkage, then the identifier has external linkage. =20
>=20
> (C23 6.2.2 "Linkages of identifiers" paragraph 4.)
>=20
> There is a prior declaration visible with internal linkage, so
> according to this paragraph the linkage should be internal.
>=20
> > If the declaration of an identifier for a function has no
> > storage-class specifier, its linkage is determined exactly as if it
> > were declared with the storage-class specifier `extern`.  If the
> > declaration of an identifier for an object has file scope and does
> > not contain the storage-class specifier `static` or `constexpr`, its
> > linkage is external. =20
>=20
> (C23 6.2.2 "Linkages of identifiers" paragraph 5.)
>=20
> The second declaration does have file scope and does not contain
> either of the storage-class specifiers `static` or `constexpr`, so
> according to this paragraph the linkage is external.
>=20
> This wording was changed in C23 to work with type inference and
> `thread_local` correctly, but it incorrectly also now covers the case
> where `extern` is used.
>=20
> ### Suggested correction
>=20
> Modify C23 6.2.2 paragraph 5:
>=20
> > If the declaration of an identifier for a function has no
> > storage-class specifier, its linkage is determined exactly as if it
> > were declared with the storage-class specifier `extern`.  If the
> > declaration of an identifier for an object has file scope and does
> > not contain <ins>any of </ins>the storage-class specifier<ins>s
> > `extern`,</ins> `static`<ins>,</ins> or `constexpr`, its linkage is
> > external. =20

This would not solve the same problem that exists for function
declarations. I'd rather suggest

 <ins>If an identifier for a function or object is declared with the
 storage class specifier `extern` where a prior declaration with
 linkage of that identifier is visible, the linkage of the identifier
 is the same as for the prior declaration.</ins>
 If the declaration of an identifier for a function has no
 storage-class specifier, its linkage is determined exactly as if it
 were declared with the storage-class specifier `extern`.  If the
 declaration of an identifier for an object has file scope and does
 not contain the storage-class specifier `static` or `constexpr`, its
 linkage is external.

Thanks
J=E2=82=91=E2=82=99=E2=82=9B

--=20
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Universit=C3=A9 de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA antenne de Strasbourg :::::::::::::::::: Camus ::
:: INRIA PIQ program Strasbourg :::::::::: piq.inria.fr ::
:: :::::::::::::::::::::::::::::::::::: =E2=98=8E +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
