From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Using static_assert in Emacs? Date: Fri, 19 Jul 2024 08:48:40 +0800 Message-ID: References: <867cdig0zu.fsf@gnu.org> <865xt2fvrj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30507"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Kangas , emacs-devel@gnu.org, eggert@cs.ucla.edu To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 19 02:49:45 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sUboe-0007o5-IR for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Jul 2024 02:49:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUbnn-0004iZ-FK; Thu, 18 Jul 2024 20:48:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sUbnm-0004iQ-9D for emacs-devel@gnu.org; Thu, 18 Jul 2024 20:48:50 -0400 Original-Received: from sonic313-9.consmr.mail.ne1.yahoo.com ([66.163.185.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUbnk-00038b-H3 for emacs-devel@gnu.org; Thu, 18 Jul 2024 20:48:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721350125; bh=LM7u5bIiuWoTwd/vQCjBB6YfrBuQWXsHdzC3AfMk174=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=cc56ffhdYqO6NzY1gDovjizfHM7Pct6+tnbTCMET2PaFKYjgBXo0f3kfI4SIeh1r4Mom7oBjz9VGpqewd9oeSfkSveLPJIw/Di/mHlQ4kX6LIQCwOThH/a+6txuKECEZ9H+7HEPjn3GBzqjnTHEzq68xywabVj1ZcE2e4A8VwDuVgd4fsu0TaFsZ+HJ7lUengY36HWGOJd4BSHXLypl9ToaeM0UdPBDfA43hB5rZQCcH48R3UwUhcXvJNOKNap+gsnsS7iTvYyE7ceZxjQd47JwZmPLZFo8PVUdkj6mMEtod0jNhOKlGsck/IKL09JX1YRTsbxStIfATMVyRgjj6wQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721350125; bh=/spQz5GGwAy0SheLq1G48WfBHjk15DPH2S06Xh6NtfA=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=TxLaYWsDsNTWBcKXzOdLlRilsOInSesFroglP1BDICSWoZBC/LDLSI8RqafzBLM0vm2qZsZETcc+YjlaiT+ansYkZhBgPbUF4c7m9JmLrnnJvDNcWiCbmJ8HbgVuG4qaawRoCMd65dvPdEw0IxrsTUZxmAU8cXK038SXr+77kXukustW9A7oszS4IO0FC5tGgiolxvWrfvKwv2sPKzToz1QfZbLGGd2FA8dStqnjkaF1pRwNsr1i5xX0XboEiEveUgAU6CmXKIFcfoYkD1llaU9SnSHIE5eYYWu2lQ4t0YLkiPn9M4jsXe1CMOvmd3001OQFooz9yiOAdQv0KClAKw== X-YMail-OSG: L75qACgVM1m4twMan4lQMHCk6NUc_wBakWW9qhTpiTLNJTIuAw1M92NHbJRO8HN DygFOUa4ldJJ14Y_m1P4RRBfjrhSeIWxv3LjYBW1V0CU0qdyx8xRlAUweJl4Pv3aUA3FBGQEc8rt C3MMNsy4wCIuGgPRExRE8ke9k6rvKoN3r0toDej2YpjtCxbp0n5sx5lz78YQQXOYbD9EebojYTi0 lpvBnGvAWauiPLzXLNMvyg9_odi3nCikx0IdUbY.9CCTkRzGptBAGMBUzLucKtOVp9tqLliaoP5x uNU0CC4L1zf_0L_qIHduKZ7X84mx6VpsLDvC2JK2DJcPIBOH_mKzw16T2ucfiiaFE9UHRDWaFe1e tlcro.5dzGPDgsL0yg2C6ZHv8dHIcjj_tlAmuLaRevIi.QxuAlCgX_anr4QvHWSaSrFaNtAVz_rE jyX5jh29SEbKYs6Q9yZ0vdEG2n1s_t3J5sPf098xKqQY_OjLZjh5ASnXLaQlQjPfIYgm5spI4xnC 2u2TBh8p_1ym9.jbD7JMzQbidBTi49MEhFIbQLN6qX5ylya9KCoZtZjllT2LiljXHaobUI6pBVTt VtjF_m99JMFuPNfKHKaPbTgFs_vYoJHipuu6C9zpgAwtmXH57yskUsDCSHkc8NI75HnUe537lphJ UnWeBcodEfuK5h1gphc70cO5rTpVq0Dy0O84T_UHGsvTYoXV7sxS9p_.V2bZ587E2NrHRyqrhjkU UWtRIWqTejmeVWusvp5Hhy5FuEocjc0J6AKMwdsCd.aHnqwmtX0RAHNphZBrRdproOwvK1EJdZFP AhhPQo92E8eY2DcWJkYgrTLom5J_Em4i5C6p0vCTbQ X-Sonic-MF: X-Sonic-ID: a60664a8-b38b-4fc8-b9d3-ca4dc11b3db8 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Fri, 19 Jul 2024 00:48:45 +0000 Original-Received: by hermes--production-sg3-85fdb5cfc8-t9jg7 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 9bc70de450de38554d66c8912fe80511; Fri, 19 Jul 2024 00:48:38 +0000 (UTC) In-Reply-To: <865xt2fvrj.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Jul 2024 20:35:44 +0300") X-Mailer: WebService/1.1.22501 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.185.32; envelope-from=luangruo@yahoo.com; helo=sonic313-9.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321812 Archived-At: Eli Zaretskii writes: >> I'm looking at something like this, where the sizes are known at >> compile >> time: >> >> #define FOO "some text" >> static_assert (sizeof buf >= sizeof FOO); >> memcpy (buf, FOO, sizeof FOO); > > If we have such code (do we?), and if there's a danger that someone > makes FOO longer but forgets to change buf, such an assertion could be > useful. IME, such code is rare, though. And our convention is to use Gnulib's verify rather than static_assert.