From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10E1B3858401; Thu, 18 May 2023 12:26:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10E1B3858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684412819; bh=9ZArihKOEJaRgNOoZ2E+nhsMNDewdQV1VQcvdBZJKuA=; h=From:To:Subject:Date:From; b=x1ScFGLEfIQ7tELLPpbIQfpzNkaqOravbRp+1nH0Xw/lI4+HctJz2lYUWdrdhwxzB ERnFdLVP1IQBEIrtya6BaCygmc78e6fh9FBIxI6fTGt3OQtTIvylLlAciEVGmbVf5z It27UWJoTyHPY0Zt41IPifTCuWNW7OLFA156oH+c= From: "simon.farre.cx at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/109902] New: gcc/g++ emits wrong column number in DWARF Date: Thu, 18 May 2023 12:26:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 12.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simon.farre.cx at gmail 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 attachments.created 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=3D109902 Bug ID: 109902 Summary: gcc/g++ emits wrong column number in DWARF Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: simon.farre.cx at gmail dot com Target Milestone: --- Created attachment 55111 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55111&action=3Dedit Contains GCC & clang dwarfdump output as well as simple source code. The DWARF spec, states in paragraph 2.14 "Declaration Coordinates" (version= 5, https://dwarfstd.org/doc/DWARF5.pdf) that: "The value of the DW_AT_decl_column attribute represents the source column number at which the first character of the identifier of the declared object appears. The value 0 indicates that no column has been specified." Below is an example of contrived C++ code: auto b =3D setfoo().setbar().setbaz(); gcc emits column meta data at these positions (represented by _): auto b =3D setfoo_().setbar_().setbaz_(); Whereas for instance clang emits it properly, according to spec: auto b =3D _setfoo()._setbar()._setbaz(); So for the following code: " const auto res1 =3D b.set_foo (10).set_bar (20).set_baz (30).finalize ([] (auto v) { return v * 2; });" The following line number program is emitted (the line number is 66 and set= _foo begins on column position 23) Address Line Column File ISA Discriminator Flags ------------------ ------ ------ ------ --- ------------- ------------- 0x0000000000401150 66 31 1 0 0 is_stmt 0x0000000000401161 66 44 1 0 0 is_stmt 0x000000000040116e 66 57 1 0 0 is_stmt 0x000000000040117b 66 71 1 0 0 is_stmt 0x000000000040126c 66 72 1 0 0 is_stmt 0x0000000000401277 66 97 1 0 0 is_stmt 0x000000000040127c 66 100 1 0 0 is_stmt Where as clang emits: 0x000000000040114b 66 23 1 0 0 is_stmt 0x000000000040115e 66 36 1 0 0 0x0000000000401171 66 49 1 0 0 0x0000000000401179 66 62 1 0 0 0x0000000000401430 66 0 1 0 0 is_stmt 0x000000000040143b 66 93 1 0 0 is_stmt prologue= _end 0x000000000040143e 66 95 1 0 0 0x0000000000401441 66 86 1 0 0 It's also questionable if GCC emits the correct meta data with respect to statements, but I guess that's a different issue.=