From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Collin Funk Newsgroups: gmane.emacs.devel Subject: Re: Using static_assert in Emacs? Date: Thu, 18 Jul 2024 09:51:09 -0700 Message-ID: <87frs6prsy.fsf@gmail.com> References: <867cdig0zu.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="36179"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org, eggert@cs.ucla.edu To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 18 18:51:55 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 1sUUME-0009EZ-U5 for ged-emacs-devel@m.gmane-mx.org; Thu, 18 Jul 2024 18:51:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUULe-0006AH-EP; Thu, 18 Jul 2024 12:51:18 -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 1sUULc-00069Y-C8 for emacs-devel@gnu.org; Thu, 18 Jul 2024 12:51:16 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUULa-0001A7-Rf; Thu, 18 Jul 2024 12:51:16 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fb0d88fdc8so6588535ad.2; Thu, 18 Jul 2024 09:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721321472; x=1721926272; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Au71/AbLGt95TV8083HXjwpfzMTL3KLZ8yULvvUBZwI=; b=bD41gDMGTV69OqiYT6wFVH2g4DyyUdqqiZUOlQ0aDeVt1ADun7AHfazSRexlfeSyU3 Aik2ZMrQe+2cOMxnpl9MYSMhzPqRKaATsqOce67oHA74FLdqs1R/hAoz+vbQd33SnNVW i7gFzJvD+6QhVmSUZ4j9513uZ7LuKqCM/td++Brhz7ecQBGfz1ndRry7LK5JUPyYn1Dq Sdl91utA9OMj2hlX17A+HDW8S9GTviGcfZcHdqfS9RWAYXyPE0l5wk0Whdu0bNQ+07xt XUcv/afflN58nT2UQAOok1MU0Z9zwFAf0tnKt0PVbYpAgmhxnZB2dq5ePSz+slQL5cWM ZrKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721321472; x=1721926272; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Au71/AbLGt95TV8083HXjwpfzMTL3KLZ8yULvvUBZwI=; b=BMx55IrjyJjatbZUbOp7CpT1/6C9bjeO8VhSCRI2p7qCiBnlfI4PwcNQBVSL57ZDKM ebWYKKFfGCXiqIoTuyoxxqY5jIJRmQta5gNt/fWl1O494WBbAkFLAcDMa8GkXlSDJk34 iaOoK5WrPodnWvAqhOPLpperhKwLznoeiQnUEvT9F+KKtwt/H20HpJMPerDHbVor82kJ uDWHHinfirrniENEBuM3vP4Q3lQi7rHrRFG7bD0oyLX+CXGULWE74JE0Kgo1317ixNcl salQNKq8//72ezgAZLlanEFuHY/jzjM80/VQu0kEi8q3wm+iKU7rSe+1XDx96hzZ2KHI gIAg== X-Forwarded-Encrypted: i=1; AJvYcCVuXngA/ScniSBYq7urjrYmuo7PH+fo8hEQ9fkeksZrS8PHhFp2u28V9KtOgIyRZeISzEPUYWr5dD/n5SDKNuiqeFyE X-Gm-Message-State: AOJu0Yxf3A9DbzhnOYTEPjg/Qvg7bumg9q7AmlMhc5ea9y5hXabQLtQt eP8HAHoiB9twUbWU87T2hjCS5MjWx/z3OeiUu3o13GyhBitByIW6 X-Google-Smtp-Source: AGHT+IE7zV46n6bogL19dBuAnEQieXThoih1GouW/lL4vPSitTLCZ49Og+3/LxuTG/VmPkajPkTvRw== X-Received: by 2002:a17:903:41c7:b0:1fb:3e52:8b5d with SMTP id d9443c01a7336-1fc4e154f9fmr50339425ad.1.1721321472206; Thu, 18 Jul 2024 09:51:12 -0700 (PDT) Original-Received: from fedora (c-67-180-36-62.hsd1.ca.comcast.net. [67.180.36.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0bc37893sm94995455ad.190.2024.07.18.09.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 09:51:11 -0700 (PDT) In-Reply-To: (Stefan Kangas's message of "Thu, 18 Jul 2024 09:39:43 -0700") Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=collin.funk1@gmail.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:321801 Archived-At: Stefan Kangas writes: >> The real question is: where and how will that be useful? > > 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); BTW, Emacs uses Gnulib's verify.h for this. So I guess just no one got around to updating it: src/lisp.h:#include src/lisp.h:verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1); src/lisp.h:/* Define Emacs versions of 's 'assert (COND)' and 's src/lisp.h: requires alignment, use verify (GCALIGNED (T)) to verify the src/lisp.h:verify (GCALIGNED (struct Lisp_Symbol)); src/lisp.h:verify (GCALIGNED (struct Lisp_Cons)); src/lisp.h:verify (GCALIGNED (struct Lisp_String)); Collin