From patchwork Thu Jul 11 13:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1959362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=PumEssgK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WKb581Hnbz1xqr for ; Thu, 11 Jul 2024 23:23:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E492383E515 for ; Thu, 11 Jul 2024 13:23:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 4C06A386C5A4 for ; Thu, 11 Jul 2024 13:22:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C06A386C5A4 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4C06A386C5A4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720704163; cv=none; b=tfmXqExvbdHqjg+6/z8AIlaZBCS825+RB6Om047wSuLhFZCgFbCO31xkWDNRwAjQz0Cvk4VUlvXooDWHGt01RqLn7Jd9/QKdTCorRMe1G5kAfnS+ShfZjWyM+9PVVHa/bqZOELPNFrHjz2P7AmLSqTwxz3zrxdwwdF4v80Xd1kc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720704163; c=relaxed/simple; bh=/XQwLk+w7ea7Uks4at20iCShljoxJmHH/PCkOql2Ls4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZHuv+APpEOw1sW2MyJu4Ta6pKWI+YKFXQpyEIWXBk8LnapY+LiBvVKs7bgT2yiq+CztRrhrEyLfL3nMr6Qi61E3ZH1HTfpieWbW8sCNfJCaqHIpRL4SQVtWHYJ75/1h9CihCsvBTQEkZ+DcMXN8hcg25B8/YfnJZi8JScPzmmNQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2c927152b4bso682322a91.2 for ; Thu, 11 Jul 2024 06:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1720704161; x=1721308961; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=w7umTOVzXDJizXn6/JXG05EUS+tRZ/wOUX7/WCpmYoE=; b=PumEssgKu1mn+dyzcXqnFRiw1+y+l8YazfgLrWyXPtYfkVKyWoaS/dWoojWShAbkn1 2dke7Tk/WLN67MO4e/w1XsTxO8s+i8PHTsCfPm4yBPXX36yYAwICywnU+ujuw7eTVdG4 kU/44jzP5DDpDFsKXhobE2HJu6o+QJzoVLKWK9PHgeJULMxi1QBpRUfVQbZBCoN0pgdK j8doxUkg49JzXXDChpJEAJWD6pqv7fxWdJVf5TYsdy3mt3raIBAjWkA/Ma1bMbyjstvZ VQEboF9/j6EFszSusUFUcLm0JQdAzxNzrWIrZ2xyhtBLXK2zSPw5hlSESHhqBZI8OR8u Ukaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720704161; x=1721308961; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w7umTOVzXDJizXn6/JXG05EUS+tRZ/wOUX7/WCpmYoE=; b=a1WwQV+oYWcxoxj4DNJtXZu4xE3Qg4bqMVKcRibYZNEb9ckevvEI+7iLQiCCPnllYv j7bt/e88h3hlzMcYkp6xgyPnGAQ2BJ1QSsMI+nStog6w44jCl75R0yyj2ePurowQUwXc Bsa7VQnImuHjBmRpeU08kAgZ5h64bVag7gJgiJ88/uG5/gffcl7G6iiHvOuhwO05stAk wZB13zA0sww10LeVH1j/VccF6aMfKmF7n4gE4kQlOobfC0FjaloIt0VjhmDOQYvgSwa9 c16hv495/yzUwC8kF4DwpGyY3iubYNSSQyzJw7GiOrUo/xbhtDmIvBgC4ZDVOJ/IpeBK KQRQ== X-Gm-Message-State: AOJu0Yzwc9R1pgufjiSLCfjwfMBIr3ILz930Kc2tqWJMmhinY3twe4qE yEZ++htZkNkznxkvzoBLJgPGt4NoImJKvUwrtxXAV6zp20qFy5hy2NDiybfXOfaqgkDFc0Sikrv Gbw== X-Google-Smtp-Source: AGHT+IExp1E2hdiapOm0EXZTNifj9w8oTpZniuYaa3XwdXkI6x4Jb8ZZ9aknPQiaizmbKifjJcbshg== X-Received: by 2002:a17:90b:3786:b0:2c9:7ebd:b957 with SMTP id 98e67ed59e1d1-2ca35c272fbmr7781110a91.11.1720704161266; Thu, 11 Jul 2024 06:22:41 -0700 (PDT) Received: from free.home ([2804:7f1:218a:d53f:1f12:68c4:3c4:d64a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c99a984512sm13736463a91.31.2024.07.11.06.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 06:22:41 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 46BDMVWF1013486 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 11 Jul 2024 10:22:32 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] [libstdc++] [testsuite] avoid arbitrary errno codes Organization: Free thinker, does not speak for AdaCore Date: Thu, 11 Jul 2024 10:22:31 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Passing an arbitrary error number to strerror* functions doesn't seem to be portable; 19_diagnostics/system_error/cons-1.cc is hitting runtime errors in the block that attempts to instantiate a std:;system_error for error number 95. The range of errno macros defined on this target doesn't reach 95. I'm changing the test to try to use a couple of select error codes, falling back to a lower error number if neither are present. Hopefully this doesn't change the nature of what is being tested for. Regstrapped on x86_64-linux-gnu, also tested with gcc-13 targeting aarch64. Ok to install? for libstdc++-v3/ChangeLog * testsuite/19_diagnostics/system_error/cons-1.cc: Use lower error numbers, preferring some macro-defined ones. --- .../19_diagnostics/system_error/cons-1.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc index 16aa960b2ee28..e227c67542411 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc @@ -37,8 +37,18 @@ int main() // 2 { - std::system_error err2(95, std::system_category(), s); - VERIFY( err2.code() == std::error_code(95, std::system_category()) ); + int eno; +#if defined EOPNOTSUPP + eno = EOPNOTSUPP; +#elif defined ENOSYS + eno = ENOSYS; +#else + // strerror (used to combine with the given message) may fail if + // the error number is out of range for the system. + eno = 42; +#endif + std::system_error err2(eno, std::system_category(), s); + VERIFY( err2.code() == std::error_code(eno, std::system_category()) ); VERIFY( std::string((err2.what(), s)).find(s) != std::string::npos ); }