From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 394953858D37; Tue, 21 Mar 2023 08:56:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 394953858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679388995; bh=vqictFm30t2NLTm6iqE0x0Pkyns3EOC+eUtMzuB54mQ=; h=From:To:Subject:Date:From; b=rpIKwp0KHfOPrVupaVjWclhkCQQlk7D9Yljx69ZVqcCHAJPIfkCaH7wBUCKp4spxm e/zQEtz5sKYJ8kYNtjMdT2uirSd9+Lg3O5XzK6E8b4OKlnUMNwjnZmOK5o0rL3MISS HunvPx4pxUuFTVWK3Dix4AaHnoGBM0ehEyCjI5S8= From: "gnu-bugzilla at ribizel dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109229] New: std::exclusive_scan narrows to initial value Date: Tue, 21 Mar 2023 08:56:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gnu-bugzilla at ribizel dot de 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=3D109229 Bug ID: 109229 Summary: std::exclusive_scan narrows to initial value Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gnu-bugzilla at ribizel dot de Target Milestone: --- Take the following piece of code: ``` #include #include #include #include #include int main() { std::vector vec{1LL << 32, 0}; std::exclusive_scan(vec.begin(), vec.end(), vec.begin(), 0); std::cout << vec[0] << '\n'; std::cout << vec[1] << '\n'; } ``` I would expect this to output 0 and 1LL<<32, but it outputs 0, 0, because T= in std::exclusive_scan is deduced as int, which is the computational type that will be used in exclusive_scan. Not sure if this is a library or standard defect, but I think this is pretty bug-prone otherwise. Other standard libr= ary implementations have the same issue, see https://github.com/NVIDIA/thrust/issues/1896 and https://github.com/llvm/llvm-project/issues/61575.=