From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5D5A23858C62; Sat, 24 Jun 2023 15:51:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D5A23858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687621889; bh=AtEpu41mGDTUyWeJHRYdRJEmwVLhkNYHYkfyUzucAwc=; h=From:To:Subject:Date:From; b=hEiYwtz17NZEwogLxyFIMAQY/PKyySXDJQCoWGHOBsRVBMe7R7OCqxexkSBei1qFo Xc+VAVMLDF0VGy6NdSAAzKR0sAlG/NEYQT8lEf0Zy8/zBvWgJOASbCTAn/BcLHASyS q50bYHiQwfdh/2dcfAYRen4QCn2CpwgHrRnDKbys= From: "jackyguo18 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/110394] New: Lambda capture receives wrong value Date: Sat, 24 Jun 2023 15:51:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jackyguo18 at hotmail dot com 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=3D110394 Bug ID: 110394 Summary: Lambda capture receives wrong value Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: jackyguo18 at hotmail dot com Target Milestone: --- Note that this doesn't occur in Clang, and to my knowledge, disabling strict aliasing and overflow would make no difference. The code submitted here is actually part of a larger library. When I go to debug it, a lambda in `GetKeys(int index, BUTTONS* keys)` captures the wrong value for `index`--it should be 0, but it's 23. Changing the capture type from value to reference causes the lambda to inexplicably call the address 0x17 (decimal 23).=