From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 46627385C32E for ; Wed, 24 Aug 2022 13:05:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46627385C32E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661346336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I9+VwmRI+l/wpoqiFXQqjnLNnkPMLa0A1dZvf5NqoIw=; b=IMY0aaG5JnY3U6cGxMjp7YH/m5VZuj6iIHCy6x4idFvORYtGxo8IZAee2kX09Tbht+o4eb kwdfhEnxkiLjPpGf7ctqi3cfxPIT+chX9WJZQUoQhYuMbqA9mIRpQ4HBrxyMr3xwSmHkTV UqSCnWNYO8txSCp/1IwXIN8z2qo/saA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-153-8Qh0ImhlORWJ_hxMcDiVyQ-1; Wed, 24 Aug 2022 09:05:32 -0400 X-MC-Unique: 8Qh0ImhlORWJ_hxMcDiVyQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 80B3780231E; Wed, 24 Aug 2022 13:05:32 +0000 (UTC) Received: from localhost (unknown [10.33.36.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A8892166B26; Wed, 24 Aug 2022 13:05:32 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add check for LWG 3741 problem case Date: Wed, 24 Aug 2022 14:05:31 +0100 Message-Id: <20220824130531.77910-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested powerpc64le-linux, pushed to trunk. -- >8 -- This LWG issue was closed as NAD, as it was just a bug in an implementation, not a defect in the standard. Libstdc++ never had that bug and always worked for the problem case. Add a test to ensure we don't regress. The problem occurs when abs is implemented using a ternary expression: return d >= d.zero() ? d : -d; If decltype(-d) is not the same as decltype(d) then this is ambiguous, because each type can be converted to the other, so there is no common type. libstdc++-v3/ChangeLog: * testsuite/20_util/duration_cast/rounding.cc: Check abs with non-reduced duration. --- libstdc++-v3/testsuite/20_util/duration_cast/rounding.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/testsuite/20_util/duration_cast/rounding.cc b/libstdc++-v3/testsuite/20_util/duration_cast/rounding.cc index af6e72d9e2e..c5179b6eb6e 100644 --- a/libstdc++-v3/testsuite/20_util/duration_cast/rounding.cc +++ b/libstdc++-v3/testsuite/20_util/duration_cast/rounding.cc @@ -58,3 +58,8 @@ static_assert( std::chrono::round(2501ms) == 3s ); static_assert( std::chrono::abs(100ms) == 100ms ); static_assert( std::chrono::abs(-100ms) == 100ms ); + +// LWG 3741. std::chrono::abs(duration) is ill-formed with non-reduced periods +using D1000 = std::chrono::duration>; +static_assert( std::chrono::abs(D1000(-2)) == D1000(2) ); +static_assert( std::is_same_v ); -- 2.37.2