From nobody Thu Feb 20 09:40:54 2025 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yz93h4VVGz5nhwP for ; Thu, 20 Feb 2025 10:48:48 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yz93f3Y0Yz3pnK for ; Thu, 20 Feb 2025 10:48:46 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of phk@critter.freebsd.dk designates 130.225.244.222 as permitted sender) smtp.mailfrom=phk@critter.freebsd.dk Received: from critter.freebsd.dk (unknown [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id EEEC089287 for ; Thu, 20 Feb 2025 10:48:37 +0000 (UTC) Received: (from phk@localhost) by critter.freebsd.dk (8.18.1/8.16.1/Submit) id 51K9eswS003142; Thu, 20 Feb 2025 09:40:54 GMT (envelope-from phk) Message-Id: <202502200940.51K9eswS003142@critter.freebsd.dk> To: current@freebsd.org Subject: Empty structures have sizeof(1) in C++ now ? From: Poul-Henning Kamp List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3140.1740044454.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Thu, 20 Feb 2025 09:40:54 +0000 X-Spamd-Result: default: False [-1.75 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-0.94)[-0.937]; NEURAL_HAM_SHORT(-0.81)[-0.815]; FORGED_SENDER(0.30)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[current@freebsd.org]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[phk]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_NEQ_ENVFROM(0.00)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; R_DKIM_NA(0.00)[]; DMARC_NA(0.00)[freebsd.dk]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_DN_NONE(0.00)[]; MLMMJ_DEST(0.00)[current@freebsd.org]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4Yz93f3Y0Yz3pnK X-Spamd-Bar: - Is this a bug ? critter phk> cat /tmp/_.c #include struct foo { }; int main(int argc, char **argv) { struct foo bar; printf("%jd %jd\n", sizeof(struct foo), sizeof(bar)); return (0); } critter phk> cc -o /tmp/a.out /tmp/_.c critter phk> /tmp/a.out 0 0 critter phk> c++ -o /tmp/a.out /tmp/_.c c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior= is deprecated [-Wdeprecated] critter phk> /tmp/a.out 1 1 -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence= .