https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80989

            Bug ID: 80989
           Summary: Incorrect .loc directives in generated assembly code
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: translation
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rnewman at compubrite dot com
  Target Milestone: ---

Created attachment 41480
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41480&action=edit
Source file and generated assembly code showing the problem.

If a source code line exceeds 512 bytes the generated assembly code will
incorrectly have .loc directives which progressively increment the line number.

Once the 512 threshold has been broken, .loc directives are added approximately
every 128 bytes into the line which mistakenly increment the line number.

GCC configured as follows:

$ /usr/local/gcc-6.3.0/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-6.3.0/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-6.3.0/libexec/gcc/x86_64-pc-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../SOURCE/configure --prefix=/usr/local/gcc-6.3.0
--enable-languages=c,c++ --with-dwarf2 --disable-libsanitizer
--disable-libcilkrts --disable-multilib
Thread model: posix
gcc version 6.3.0 (GCC)

--------------
attached source code compiled as follows:
$ /usr/local/gcc-6.3.0/bin/g++ -S -g foo5.cc

As can be seen, foo5.cc, line 5 is very long, (512 bytes), yet in the generated
assembly source code, foo5.s, line 16 has the correct .loc directive:
    .loc 1 5 0
But, foo5.s, line 35, incorrectly has:
    .loc 1 6 0
Then again at line 54:
    .loc 1 7 0
And at line 73:
    .loc 1 8 0
And again at line 92:
    .loc 1 9 0

There are only 6 total lines in foo5.cc.

It appears that for each 128 bytes a new .loc directive is put out
corresponding to any whitespace, rather than just new lines, but this is only
triggered if the line exceeds or meets 512 bytes.

Reply via email to