public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236
@ 2022-09-21 17:36 gscfq@t-online.de
  2022-09-22  6:48 ` [Bug c/107002] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-09-21 17:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107002
           Summary: [13 Regression] ICE in column_range, at
                    diagnostic-show-locus.cc:2236
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started between 20220828 and 20220904 :
(derived from g++.dg/parse/expr3.C)


$ cat z1.c
#define test(lower, higher, a, b, c, d) \
  char test##line[ (a higher b lower c higher d) == 0 ? -1 : 1];
test (|, ^, 1, 2, 2, 1)


$ gcc-13-20220918 -c z1.c -ftrack-macro-expansion=0
z1.c:3:1: warning: result of '2^1' is 3; did you mean '1 << 1' (2)?
[-Wxor-used-as-pow]
    3 | test (|, ^, 1, 2, 2, 1)
      | ^~~~

z1.c:3:1: internal compiler error: in column_range, at
diagnostic-show-locus.cc:2236
0x79d3b3 column_range
        ../../gcc/diagnostic-show-locus.cc:2236
0x1ecb213 column_range
        ../../gcc/input.h:96
0x1ecb213 add_hint
        ../../gcc/diagnostic-show-locus.cc:2482
0x1ecb76c print_trailing_fixits
        ../../gcc/diagnostic-show-locus.cc:2551
0x1ecb76c print_line
        ../../gcc/diagnostic-show-locus.cc:2790
0x1ecf60f diagnostic_show_locus(diagnostic_context*, rich_location*,
diagnostic_t)
        ../../gcc/diagnostic-show-locus.cc:2874
0x8bc715 c_diagnostic_finalizer
        ../../gcc/c-family/c-opts.cc:172
0x1ebf8ea diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ../../gcc/diagnostic.cc:1557
0x1ebffea diagnostic_impl
        ../../gcc/diagnostic.cc:1712
0x1ec2512 warning_at(rich_location*, int, char const*, ...)
        ../../gcc/diagnostic.cc:1864
0x8f6119 check_for_xor_used_as_pow(unsigned int, tree_node*, unsigned int,
tree_node*)
        ../../gcc/c-family/c-warn.cc:3855
0x7ff0ed parser_build_binary_op(unsigned int, tree_code, c_expr, c_expr)
        ../../gcc/c/c-typeck.cc:3994
0x824dfe c_parser_binary_expression
        ../../gcc/c/c-parser.cc:8085
0x825ccb c_parser_conditional_expression
        ../../gcc/c/c-parser.cc:7653
0x826674 c_parser_expr_no_commas
        ../../gcc/c/c-parser.cc:7567
0x826922 c_parser_expression
        ../../gcc/c/c-parser.cc:10782
0x8166bb c_parser_postfix_expression
        ../../gcc/c/c-parser.cc:9183
0x822fca c_parser_unary_expression
        ../../gcc/c/c-parser.cc:8311
0x8242ef c_parser_cast_expression
        ../../gcc/c/c-parser.cc:8152
0x8245bb c_parser_binary_expression
        ../../gcc/c/c-parser.cc:7955

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
@ 2022-09-22  6:48 ` rguenth at gcc dot gnu.org
  2022-09-22 12:49 ` dmalcolm at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-22  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
                 CC|                            |dmalcolm at gcc dot gnu.org
           Keywords|                            |diagnostic

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
  2022-09-22  6:48 ` [Bug c/107002] " rguenth at gcc dot gnu.org
@ 2022-09-22 12:49 ` dmalcolm at gcc dot gnu.org
  2022-09-22 19:25 ` [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-09-22 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-09-22
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |dmalcolm at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Probably introduced by r13-2386-gbedfca647a9e9c1a, which added
-Wxor-used-as-pow.

Failing assertion in column_range's ctor:

2233      column_range (int start_, int finish_) : start (start_), finish
(finish_)
2234      {
2235        /* We must have either a range, or an insertion.  */
2236        gcc_assert (start <= finish || finish == start - 1);
2237      }

where:

(gdb) p start_
$1 = 5
(gdb) p finish_
$2 = 0

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
  2022-09-22  6:48 ` [Bug c/107002] " rguenth at gcc dot gnu.org
  2022-09-22 12:49 ` dmalcolm at gcc dot gnu.org
@ 2022-09-22 19:25 ` marxin at gcc dot gnu.org
  2022-10-18  8:42 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-22 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
            Summary|[13 Regression] ICE in      |[13 Regression] ICE in
                   |column_range, at            |column_range, at
                   |diagnostic-show-locus.cc:22 |diagnostic-show-locus.cc:22
                   |36                          |36 since
                   |                            |r13-2386-gbedfca647a9e9c1a

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #1)
> Probably introduced by r13-2386-gbedfca647a9e9c1a, which added

Yes.

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-09-22 19:25 ` [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a marxin at gcc dot gnu.org
@ 2022-10-18  8:42 ` rguenth at gcc dot gnu.org
  2023-03-28 14:24 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-10-18  8:42 ` rguenth at gcc dot gnu.org
@ 2023-03-28 14:24 ` jakub at gcc dot gnu.org
  2023-03-28 16:34 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-28 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
David, any progress here?
Should the diagnostic callers be more careful when passing multiple fixit
locations to make sure they don't overlap (I think in this case they are even
the exact same location), or should diagnostic-show-locus.cc recover from it?
Given the same location for both, they are equal:
(gdb) p last_correction->m_affected_bytes
$34 = {start = 1, finish = 4}
(gdb) p affected_bytes
$35 = {start = 1, finish = 4}
and so trying to create a column range for finish + 1 of the former to start -
1
of the latter is invalid.

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-03-28 14:24 ` jakub at gcc dot gnu.org
@ 2023-03-28 16:34 ` dmalcolm at gcc dot gnu.org
  2023-03-28 18:36 ` cvs-commit at gcc dot gnu.org
  2023-03-28 18:39 ` dmalcolm at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-03-28 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 54778
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54778&action=edit
Untested patch

(In reply to Jakub Jelinek from comment #3)
> David, any progress here?

I've currently testing the attached patch.

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-03-28 16:34 ` dmalcolm at gcc dot gnu.org
@ 2023-03-28 18:36 ` cvs-commit at gcc dot gnu.org
  2023-03-28 18:39 ` dmalcolm at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-28 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:22c3a6c3c118283dfef1b9928dd21110098679b7

commit r13-6912-g22c3a6c3c118283dfef1b9928dd21110098679b7
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Mar 28 14:34:49 2023 -0400

    Don't emit -Wxor-used-as-pow on macro expansions [PR107002]

    PR c/107002 reports an assertion failure from deep inside the
    diagnostic_shows_locus when attempting to print fix-it hints relating
    to -Wxor-used-as-pow.  The case involves macro expansions with
    -ftrack-macro-expansion=0.

    It doesn't seem to make much sense to emit this warning for macro
    expansions, so this patch updates the warning not to (which seems
    to also be clang's behavior).  The patch also adds some bulletproofing
    to diagnostic-show-locus.cc to be more robust against such invalid
    fix-it hints.

    Doing so fixes the ICE.

    gcc/c-family/ChangeLog:
            PR c/107002
            * c-common.h (check_for_xor_used_as_pow): Add "rhs_loc" param.
            * c-warn.cc (check_for_xor_used_as_pow): Add "rhs_loc" param.
            Reject cases where involving macro expansions.

    gcc/c/ChangeLog:
            PR c/107002
            * c-typeck.cc (parser_build_binary_op): Update for new param of
            check_for_xor_used_as_pow.

    gcc/cp/ChangeLog:
            PR c/107002
            * parser.cc (cp_parser_binary_expression): Update for new param of
            check_for_xor_used_as_pow.

    gcc/ChangeLog:
            PR c/107002
            * diagnostic-show-locus.cc (column_range::column_range): Factor
            out assertion conditional into...
            (column_range::valid_p): ...this new function.
            (line_corrections::add_hint): Don't attempt to consolidate hints
            if it would lead to invalid column_range instances.

    gcc/testsuite/ChangeLog:
            PR c/107002
            * c-c++-common/Wxor-used-as-pow-1.c: Add macro test.
            * c-c++-common/Wxor-used-as-pow-pr107002-0.c: New test.
            * c-c++-common/Wxor-used-as-pow-pr107002-1.c: New test.
            * c-c++-common/Wxor-used-as-pow-pr107002-2.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a
  2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-03-28 18:36 ` cvs-commit at gcc dot gnu.org
@ 2023-03-28 18:39 ` dmalcolm at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-03-28 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above patch

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

end of thread, other threads:[~2023-03-28 18:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 17:36 [Bug c/107002] New: [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 gscfq@t-online.de
2022-09-22  6:48 ` [Bug c/107002] " rguenth at gcc dot gnu.org
2022-09-22 12:49 ` dmalcolm at gcc dot gnu.org
2022-09-22 19:25 ` [Bug c/107002] [13 Regression] ICE in column_range, at diagnostic-show-locus.cc:2236 since r13-2386-gbedfca647a9e9c1a marxin at gcc dot gnu.org
2022-10-18  8:42 ` rguenth at gcc dot gnu.org
2023-03-28 14:24 ` jakub at gcc dot gnu.org
2023-03-28 16:34 ` dmalcolm at gcc dot gnu.org
2023-03-28 18:36 ` cvs-commit at gcc dot gnu.org
2023-03-28 18:39 ` dmalcolm at gcc dot gnu.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).