From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 8C9F81F9FC for ; Sat, 27 Mar 2021 11:43:44 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C1430120AFC; Sat, 27 Mar 2021 20:42:44 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B3822120AFB for ; Sat, 27 Mar 2021 20:42:41 +0900 (JST) Received: by filterdrecv-p3iad2-7d7c446bd4-bjl68 with SMTP id filterdrecv-p3iad2-7d7c446bd4-bjl68-20-605F1A6A-2 2021-03-27 11:43:38.037072225 +0000 UTC m=+321032.359694468 Received: from herokuapp.com (unknown) by ismtpd0170p1mdw1.sendgrid.net (SG) with ESMTP id rOX4W_G8Tkm-JAXzHUJe-A for ; Sat, 27 Mar 2021 11:43:37.908 +0000 (UTC) Date: Sat, 27 Mar 2021 11:43:38 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79094 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17752 X-Redmine-Issue-Author: Eregon X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0dBdPTMc4RG2ZaV7GOVX?= =?us-ascii?Q?3=2FEyp=2FoDXxL2ELxU+K1kba165rrla1sQo4uYFUg?= =?us-ascii?Q?G9jexyX5ntFDn9cvqkS6A9fSkIMbUyZFO6iYAbY?= =?us-ascii?Q?x+bjsmrVpSgPm6cj9X8FWUoVxhulZy56VquE3dk?= =?us-ascii?Q?eFYwHwp4uAyRdeeBi3XulTBNcoSOd+N2dbFY8KV?= =?us-ascii?Q?Do3Y4hAH0UJyEem0U=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103059 Subject: [ruby-core:103059] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17752 has been updated by Eregon (Benoit Daloze). The `#if UNDEFINED_IDENTIFIER` seems fairly rare (56 vs 637), so it also seems more consistent to always use `#ifdef` if the identifier might not always be defined. One example is: ```c #if HAVE_RB_EXT_RACTOR_SAFE ``` vs ```c #ifdef HAVE_RB_EXT_RACTOR_SAFE ``` The second seems better to me, and is more explicit about the fact this might not be defined. The value of the macro ultimately does not matter for all `HAVE_` macros. ---------------------------------------- Feature #17752: Enable -Wundef for C extensions in repository https://bugs.ruby-lang.org/issues/17752#change-91120 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal ---------------------------------------- I would like to enable `-Wundef` for C extensions built/bundled with CRuby. >From https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html > -Wundef > Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero. I found this warning to be quite useful, notably when investigating why a given C extension did not include some code I expected, and then building those extensions on TruffleRuby. There are a couple places not respecting this currently but they seem trivial to fix, I can do that. For instance a confusing case is: https://github.com/ruby/ruby/blob/9143d21b1bf2f16b1e847d569a588510726d8860/ext/nkf/nkf-utf8/nkf.h#L19 ``` #if DEFAULT_NEWLINE == 0x0D0A ``` which without -Wundef would just exclude the code without any warning if DEFAULT_NEWLINE is not defined. I'm not sure if we should/can enable it for C extensions in general (installed as gems), as if a C extensions uses -Werror and would have such a warning it would no longer build. I can make a PR for this. I'm not sure where to add -Wundef though, should it be in https://github.com/ruby/ruby/blob/9143d21b1bf2f16b1e847d569a588510726d8860/configure.ac#L620, or maybe in mkmf.rb? -- https://bugs.ruby-lang.org/