public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lhyatt at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/105608] [11/12/13/14 Regression] ICE: in linemap_add with a really long defined macro on the command line r11-338-g2a0225e47868fbfc
Date: Tue, 30 Jan 2024 22:05:44 +0000	[thread overview]
Message-ID: <bug-105608-4-EJSvzTh6Tj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105608-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #13 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
I think I understand why it is platform dependent. The location being assigned
to the restored macros is pfile->directive_line, which was stored relative to
the original line map instance, before replacing it with the one from the PCH.
So looking that location up in the new line_maps instance produces some value
that is dependent on exactly what was stored in the old and new line maps. In
particular it will depend on stuff that was included internally such as
/usr/include/stdc-predef.h. The output with -fdump-internal-locations would
confirm it, but I am not sure it's too important to understand all the ways
that this location is wrong, since it needs to just get fixed regardless...
it's not even trying to be correct right now.

This patch in libcpp would stabilize the output to be the same on all
platforms:

=====
diff --git a/libcpp/pch.cc b/libcpp/pch.cc
index e156fe257b3..08df0f8a86d 100644
--- a/libcpp/pch.cc
+++ b/libcpp/pch.cc
@@ -838,7 +838,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
              != NULL)
            {
              _cpp_clean_line (r);
-             if (!_cpp_create_definition (r, h, 0))
+             if (!_cpp_create_definition (r, h, r->line_table->highest_line))
                abort ();
              _cpp_pop_buffer (r);
            }
=====

It would change the location to be always line 3 in the source file, matching
the "wrong" result you get now on i386-pc-solaris2.11 . The test case would
need adjustment to match. I am going to ask if it can be approved for GCC 14, I
think it is worth it to not use an unpredictable location here.

  parent reply	other threads:[~2024-01-30 22:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-15  8:08 [Bug preprocessor/105608] New: [13 Regression] ICE: in linemap_add, at libcpp/line-map.cc:502 on ovito-3.7.1 slyfox at gcc dot gnu.org
2022-05-16  7:12 ` [Bug preprocessor/105608] [11/12/13 Regression] ICE: in linemap_add, at libcpp/line-map.cc:502 on ovito-3.7.1 since r11-338-g2a0225e47868fbfc marxin at gcc dot gnu.org
2022-05-16  7:30 ` pinskia at gcc dot gnu.org
2022-05-16  8:12 ` rguenth at gcc dot gnu.org
2023-05-02 20:56 ` [Bug preprocessor/105608] [11/12/13/14 Regression] ICE: in linemap_add with a really long defined macro on the command line r11-338-g2a0225e47868fbfc lhyatt at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
2023-12-15 21:30 ` lhyatt at gcc dot gnu.org
2024-01-27  4:30 ` cvs-commit at gcc dot gnu.org
2024-01-27 12:56 ` cvs-commit at gcc dot gnu.org
2024-01-27 17:08 ` cvs-commit at gcc dot gnu.org
2024-01-27 21:51 ` cvs-commit at gcc dot gnu.org
2024-01-27 21:53 ` lhyatt at gcc dot gnu.org
2024-01-30 13:57 ` ro at gcc dot gnu.org
2024-01-30 14:38 ` lhyatt at gcc dot gnu.org
2024-01-30 14:54 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-01-30 22:05 ` lhyatt at gcc dot gnu.org [this message]
2024-01-31 14:49 ` lhyatt at gcc dot gnu.org
2024-02-01 14:17 ` cvs-commit at gcc dot gnu.org
2024-02-22 14:45 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105608-4-EJSvzTh6Tj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).