From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9796A385841B; Sat, 10 Jun 2023 14:41:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9796A385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686408063; bh=x74+/xkyj22iRRwAWiN8EVRPzCYJj5pQLxjuEiZ0HFA=; h=From:To:Subject:Date:From; b=mXx8Vm86P4zgRpGswIfgtTgNISLHAUecCfth2gU7GMfmIABsXUEDyvm32xOzb3H6Q FwSrIA6rLcnyygAQLbd8RTgGJPXBvygV4IF90KiUT2X0VXKB6JM/P9+Bm4D6ejq0gW ErInCymia2yN18JvQOM17hIOXalitZF5wLHyMI5o= From: "jun at junz dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110204] New: Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior) Date: Sat, 10 Jun 2023 14:41:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jun at junz dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110204 Bug ID: 110204 Summary: Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jun at junz dot org Target Milestone: --- Given code: #include #include #include std::map m; std::vector foo() { return ranges::to(m | ranges::views::keys); } GCC trunk reports: /opt/compiler-explorer/gcc-trunk-20230610/include/c++/14.0.0/bits/stl_itera= tor_base_funcs.h:175:9: warning: iteration 9223372036854775807 invokes undefined behavior [-Waggressive-loop-optimizations] 175 | while (__n--) | ^~~~~ /opt/compiler-explorer/gcc-trunk-20230610/include/c++/14.0.0/bits/stl_itera= tor_base_funcs.h:175:9: note: within this loop while Clang and GCC 13 both say OK. I think this is a regression. goldbolt link: https://godbolt.org/z/W33aMqr5c=