public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers
@ 2004-05-11 19:03 nikolay at etnus dot com
  2004-05-11 19:07 ` [Bug c++/15369] " nikolay at etnus dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: nikolay at etnus dot com @ 2004-05-11 19:03 UTC (permalink / raw)
  To: gcc-bugs

Consider this program compiled with 
g++ -g tx_linenumber.cxx -o tx_linenumber
-Wl,-rpath,/home/compilers/gnu/gcc/3.4.0/i386-linux/lib:/home/compilers/gnu/gcc/3.4.0/i386-linux/lib
------------------------------------------
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class test {
public:
  test(int a) {_a = a;_b = a*a;};
  void break_point() { int b=_b; }
  ~test() { };
private:
  int _a;
  int _b;
};

int main()
{

  test t1(1);
  t1.break_point();
  return 0;
}
-------------------------------------------
If you set a breakpoint in any debugger (ddt, Totalview) and run to it, 
the linenumber would be wrong. The readelf -wl shows, that compiler emitted 
wrong linenumber: 

Set File Name to entry 55 in the File Name Table (--> This is wrong file)
  Advance Line by -68 to 9
  Copy
  Extended opcode 2: set Address to 0x80488ca
  Special opcode 11: advance Address by 0 to 0x80488ca and Line by 1 to 10

The problem is, that PC 0x80488ca corresponds to _GLOBAL__I_main() that can be
in file 55.

-- 
           Summary: 3.4.0 Compiler emits wrong linenumbers
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nikolay at etnus dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15369] 3.4.0 Compiler emits wrong linenumbers
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
@ 2004-05-11 19:07 ` nikolay at etnus dot com
  2004-05-11 19:12 ` nikolay at etnus dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nikolay at etnus dot com @ 2004-05-11 19:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nikolay at etnus dot com  2004-05-10 20:13 -------
Created an attachment (id=6255)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6255&action=view)
ScreenShot to illustrate problem (Totalview)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15369] 3.4.0 Compiler emits wrong linenumbers
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
  2004-05-11 19:07 ` [Bug c++/15369] " nikolay at etnus dot com
@ 2004-05-11 19:12 ` nikolay at etnus dot com
  2004-05-11 19:40 ` [Bug debug/15369] [3.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nikolay at etnus dot com @ 2004-05-11 19:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nikolay at etnus dot com  2004-05-10 20:15 -------
Created an attachment (id=6256)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6256&action=view)
ScreenShot (ddd)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/15369] [3.4 Regression] Compiler emits wrong linenumbers
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
  2004-05-11 19:07 ` [Bug c++/15369] " nikolay at etnus dot com
  2004-05-11 19:12 ` nikolay at etnus dot com
@ 2004-05-11 19:40 ` pinskia at gcc dot gnu dot org
  2004-06-21 21:23 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-11 19:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-10 20:28 -------
Confirmed.  A 3.4.0 regression but fixed in 3.5.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |debug
     Ever Confirmed|                            |1
           Keywords|                            |wrong-debug
      Known to fail|                            |3.4.0
      Known to work|                            |3.5.0 3.3.3
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-10 20:28:06
               date|                            |
            Summary|3.4.0 Compiler emits wrong  |[3.4 Regression] Compiler
                   |linenumbers                 |emits wrong linenumbers
   Target Milestone|---                         |3.4.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/15369] [3.4 Regression] Compiler emits wrong linenumbers
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
                   ` (2 preceding siblings ...)
  2004-05-11 19:40 ` [Bug debug/15369] [3.4 Regression] " pinskia at gcc dot gnu dot org
@ 2004-06-21 21:23 ` mmitchel at gcc dot gnu dot org
  2004-08-29 18:53 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-21 21:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-21 21:23 -------
Postponed until GCC 3.4.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.1                       |3.4.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug debug/15369] [3.4 Regression] Compiler emits wrong linenumbers
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
                   ` (3 preceding siblings ...)
  2004-06-21 21:23 ` mmitchel at gcc dot gnu dot org
@ 2004-08-29 18:53 ` mmitchel at gcc dot gnu dot org
  2004-10-15  7:39 ` [Bug c++/15369] "Wrong" line number for static constructor function rth at gcc dot gnu dot org
  2005-01-14  3:00 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 18:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-29 18:53 -------
Postponed until GCC 3.4.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.2                       |3.4.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15369] "Wrong" line number for static constructor function
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
                   ` (4 preceding siblings ...)
  2004-08-29 18:53 ` mmitchel at gcc dot gnu dot org
@ 2004-10-15  7:39 ` rth at gcc dot gnu dot org
  2005-01-14  3:00 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-10-15  7:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-10-15 07:39 -------
The bug here happens because once we start processing functions, input_location
changes effectively at random.  E.g. walk_tree sets input_location based on the
tree node that we're currently processing.  Which is, frankly, insane.

It also turns out to be remarkably difficult to get hold of the locus for the
end of file because c-lex and the c++ front end conspire to discard the locus
that the preprocessor helpfully collects for CPP_EOF.

I'll note that this has only "worked" by chance in previous versions and on 
mainline.  What line number we get for the static constructors depends on what
order we find ourselves processing the functions (inlined, not inlined, etc).
I.e. essentially random.  So it seems a streach to call this a 3.4 regression.

There appears to be no non-invasive solution for this for 3.4.  My personal
feeling is that some C++ lexer guy ought to fix this for mainline, and we 
should WONTFIX the problem for previous versions.  It's definitely non-critical
and there's a perfectly good workaround for users -- set breakpoints on
function names rather than line numbers.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
          Component|debug                       |c++
  GCC build triplet|i686-pc-linux               |
   GCC host triplet|i686-pc-linux               |
 GCC target triplet|i686-pc-linux               |
      Known to work|4.0 3.3.3                   |
   Last reconfirmed|2004-05-10 20:28:06         |2004-10-15 07:39:18
               date|                            |
            Summary|[3.4 Regression] Compiler   |"Wrong" line number for
                   |emits wrong linenumbers     |static constructor function
   Target Milestone|3.4.3                       |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15369] "Wrong" line number for static constructor function
  2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
                   ` (5 preceding siblings ...)
  2004-10-15  7:39 ` [Bug c++/15369] "Wrong" line number for static constructor function rth at gcc dot gnu dot org
@ 2005-01-14  3:00 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-14  3:00 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-10-15 07:39:18         |2005-01-14 03:00:09
               date|                            |
   Target Milestone|4.0.0                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15369


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-01-14  3:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-11 19:03 [Bug c++/15369] New: 3.4.0 Compiler emits wrong linenumbers nikolay at etnus dot com
2004-05-11 19:07 ` [Bug c++/15369] " nikolay at etnus dot com
2004-05-11 19:12 ` nikolay at etnus dot com
2004-05-11 19:40 ` [Bug debug/15369] [3.4 Regression] " pinskia at gcc dot gnu dot org
2004-06-21 21:23 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:53 ` mmitchel at gcc dot gnu dot org
2004-10-15  7:39 ` [Bug c++/15369] "Wrong" line number for static constructor function rth at gcc dot gnu dot org
2005-01-14  3:00 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).