public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand
@ 2023-11-13  2:28 141242068 at smail dot nju.edu.cn
  2023-11-13  2:47 ` [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: 141242068 at smail dot nju.edu.cn @ 2023-11-13  2:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112499
           Summary: GCC: 14: internal compiler error: output_operand:
                    invalid expression as operand
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/MdacfWqhr

When attempting to compile this program with `gcc-14 -O1`, gcc crashes:
```
#include <stdint.h>

int f(void) {
  static uintptr_t a = ((char *)&&l3 - (char *)&&l2) +
                       ((char *)&&l1 - (char *)&&l2);
l1:
l2:
l3:
  return a;
}
```

If removing the qualifier `static`, then this crash disappears.

The crash output:
```
<source>:10:1: internal compiler error: output_operand: invalid expression as
operand
   10 | }
      | ^
0x238b15e internal_error(char const*, ...)
        ???:0
0xd01147 output_operand_lossage(char const*, ...)
        ???:0
0xd01c71 output_addr_const(_IO_FILE*, rtx_def*)
        ???:0
0xd01a53 output_addr_const(_IO_FILE*, rtx_def*)
        ???:0
0xd01ae5 output_addr_const(_IO_FILE*, rtx_def*)
        ???:0
0x14cec92 assemble_integer_with_op(char const*, rtx_def*)
        ???:0
0x14cecf1 default_assemble_integer(rtx_def*, unsigned int, int)
        ???:0
0x14ced7f assemble_integer(rtx_def*, unsigned int, unsigned int, int)
        ???:0
0x14e1cae assemble_variable(tree_node*, int, int, int)
        ???:0
0x14e62ae symbol_table::output_variables()
        ???:0
0xc027bb symbol_table::finalize_compilation_unit()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
@ 2023-11-13  2:47 ` pinskia at gcc dot gnu.org
  2023-11-13  2:47 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-13  2:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5
      Known to fail|                            |5.3.0, 5.5.0, 6.1.0
      Known to work|                            |4.9.4, 5.2.0
          Component|c                           |middle-end
            Summary|GCC: 14: internal compiler  |[11/12/13/14 Regression]
                   |error: output_operand:      |ICE in output_operand:
                   |invalid expression as       |invalid expression as
                   |operand                     |operand with addition of 2
                   |                            |differences of address of
                   |                            |labels
           Keywords|                            |ice-on-invalid-code

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
  2023-11-13  2:47 ` [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels pinskia at gcc dot gnu.org
@ 2023-11-13  2:47 ` pinskia at gcc dot gnu.org
  2023-11-13 14:25 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-13  2:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-11-13
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
  2023-11-13  2:47 ` [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels pinskia at gcc dot gnu.org
  2023-11-13  2:47 ` pinskia at gcc dot gnu.org
@ 2023-11-13 14:25 ` jakub at gcc dot gnu.org
  2024-03-07 21:02 ` law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-13 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r6-3469-gef537cc859dd149230454398078da6d3128cfd9a
Testcase without headers:

typedef unsigned __INTPTR_TYPE__ uintptr_t;

int
foo (void)
{
  static uintptr_t a = ((char *)&&l3 - (char *)&&l2) + ((char *)&&l1 - (char
*)&&l2);
l1:
l2:
l3:
  return a;
}

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
                   ` (2 preceding siblings ...)
  2023-11-13 14:25 ` jakub at gcc dot gnu.org
@ 2024-03-07 21:02 ` law at gcc dot gnu.org
  2024-03-12 13:22 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |law at gcc dot gnu.org

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
                   ` (3 preceding siblings ...)
  2024-03-07 21:02 ` law at gcc dot gnu.org
@ 2024-03-12 13:22 ` jakub at gcc dot gnu.org
  2024-03-19 16:49 ` jakub at gcc dot gnu.org
  2024-04-07  5:32 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-12 13:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6-13 has been released with this bug, so P2.

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
                   ` (4 preceding siblings ...)
  2024-03-12 13:22 ` jakub at gcc dot gnu.org
@ 2024-03-19 16:49 ` jakub at gcc dot gnu.org
  2024-04-07  5:32 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-19 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Or consider
typedef unsigned __INTPTR_TYPE__ uintptr_t;
volatile int v;

int
foo (int x)
{
  static uintptr_t a = ((char *)&&l2 - (char *)&&l1) + ((char *)&&l4 - (char
*)&&l3) + ((char *)&&l6 - (char *)&&l5);
  void *b[] = { &&l1, &&l2, &&l3, &&l4, &&l5, &&l6 };
l1:
  ++v;
l2:
  ++v;
l3:
  ++v;
l4:
  ++v;
l5:
  ++v;
l6:
  ++v;
  if (x >= 0 && x <= 5)
    {
      x += 42;
      goto *b[x - 42];
    }
  return a;
}
That is even older.
r0-79351-g7771bb621aad43c7d0e21ccec4922dd3beac9cb6
still used to reject that:
error: initializer element is not computable at load time
r0-79390-g7ffb5e78794b6d8f8094d7c928e6f0e94b62cad6
already accepts but assembler doesn't handle that:
pr112499-2.s:58: Error: invalid operands (*ABS* and .text sections) for `-'
pr112499-2.s:58: Error: invalid operands (*ABS* and .text sections) for `-'
pr112499-2.s:58: Error: invalid operands (.text and .text sections) for `+'
        .quad   .L3-.L6-.L4-.L2+.L7+.L5
Guess we can only accept a subtraction of 2 labels, not addition of 2 labels or
something more complex.

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

* [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels
  2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
                   ` (5 preceding siblings ...)
  2024-03-19 16:49 ` jakub at gcc dot gnu.org
@ 2024-04-07  5:32 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-07  5:32 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 100595 ***

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

end of thread, other threads:[~2024-04-07  5:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13  2:28 [Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand 141242068 at smail dot nju.edu.cn
2023-11-13  2:47 ` [Bug middle-end/112499] [11/12/13/14 Regression] ICE in output_operand: invalid expression as operand with addition of 2 differences of address of labels pinskia at gcc dot gnu.org
2023-11-13  2:47 ` pinskia at gcc dot gnu.org
2023-11-13 14:25 ` jakub at gcc dot gnu.org
2024-03-07 21:02 ` law at gcc dot gnu.org
2024-03-12 13:22 ` jakub at gcc dot gnu.org
2024-03-19 16:49 ` jakub at gcc dot gnu.org
2024-04-07  5:32 ` pinskia 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).