Bug 103788 - [13/14/15/16/17 Regression] '-fcompare-debug' failure (length) w/ -O1 (statement-frontiers)
Summary: [13/14/15/16/17 Regression] '-fcompare-debug' failure (length) w/ -O1 (statem...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 12.0
: P2 normal
Target Milestone: 13.5
Assignee: Not yet assigned to anyone
URL:
Keywords: compare-debug-failure
Depends on:
Blocks: gstatement-frontiers
  Show dependency treegraph
 
Reported: 2021-12-21 12:01 UTC by Arseny Solokha
Modified: 2026-04-22 14:28 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2021-12-21 12:01:05 UTC
gcc 12.0.0 20211219 snapshot (g:fcbf94a5be9e0c1ecad92da773a6632b86b7f70a) fails -fcompare-debug check when compiling the following testcase w/ -O1:

int
bar (void);

int
foo (int x)
{
  int i;

  for (i = 0; i <= __INT_MAX__; ++i)
    x += bar () < (x ? 2 : 1);

  return x;
}

% gcc-12.0.0 -O1 -fcompare-debug -c ohtuq2al.c
gcc-12.0.0: error: ohtuq2al.c: '-fcompare-debug' failure (length)

--- ohtuq2al.c.gkd	2021-12-21 18:49:49.840375354 +0700
+++ ohtuq2al.gk.c.gkd	2021-12-21 18:49:49.891375611 +0700
@@ -75,7 +75,7 @@
         (expr_list:REG_UNUSED (reg:CC 17 flags)
             (nil))))
 (jump_insn # 0 0 3 (set (pc)
-        (label_ref #)) "ohtuq2al.c":10:17# {jump}
+        (label_ref #)) "ohtuq2al.c":10:5# {jump}
      (nil)
  -> 3)
 (barrier # 0 0)
Comment 1 Martin Liška 2021-12-21 13:57:02 UTC
Likely latent which was exposed with r9-3352-g87bd153645f393a1.
Comment 2 Drea Pinski 2021-12-21 18:46:02 UTC
(In reply to Martin Liška from comment #1)
> Likely latent which was exposed with r9-3352-g87bd153645f393a1.
Comment 3 Drea Pinski 2021-12-21 18:51:23 UTC
(In reply to Andrew Pinski from comment #2)
> (In reply to Martin Liška from comment #1)
> > Likely latent which was exposed with r9-3352-g87bd153645f393a1.

here is a slightly modified (just line rather than column change) which fails in GCC 8 also:
int
bar (void);

int
foo (int x)
{
  int i;

  for (i = 0; i <= __INT_MAX__; ++i)
    x += bar () < (
    x ? 2 : 1 );
  return x;
}
Comment 4 Drea Pinski 2021-12-21 19:00:23 UTC
In .gimple already:
-g2:
  [/app/example.cpp:11:5] goto <D.1986>;
vs -g0:
  [/app/example.cpp:10:17] goto <D.1986>;


-g2:
  <D.1986>:;
  # DEBUG BEGIN STMT;
  SAVE_EXPR <bar () < (x != 0 ? 2 : 1)>;, x = (SAVE_EXPR <bar () < (x != 0 ? 2 : 1)>) + x;;
  # DEBUG BEGIN STMT;
   ++i;
  # DEBUG BEGIN STMT;
  goto <D.1986>;


vs -g0:
  <D.1986>:;
  SAVE_EXPR <bar () < (x != 0 ? 2 : 1)>;, x = (SAVE_EXPR <bar () < (x != 0 ? 2 : 1)>) + x;;
   ++i;
  goto <D.1986>;
Comment 5 Arseny Solokha 2021-12-22 04:38:14 UTC
Can it be related to PR94276?
Comment 6 Martin Liška 2021-12-22 08:42:42 UTC
> here is a slightly modified (just line rather than column change) which
> fails in GCC 8 also:
> int
> bar (void);
> 
> int
> foo (int x)
> {
>   int i;
> 
>   for (i = 0; i <= __INT_MAX__; ++i)
>     x += bar () < (
>     x ? 2 : 1 );
>   return x;
> }

This one started with r8-5241-g8697bf9f46f36168 which introduced -gstatement-frontiers.
Comment 7 Jakub Jelinek 2022-01-28 12:23:38 UTC
Dup of the many -gstatement-frontiers -fcompare-debug issues.  No idea what to do about those.
Comment 8 Richard Biener 2022-05-27 09:46:57 UTC
GCC 9 branch is being closed
Comment 9 Jakub Jelinek 2022-06-28 10:47:33 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 10 Richard Biener 2023-07-07 10:41:53 UTC
GCC 10 branch is being closed.
Comment 11 Richard Biener 2024-07-19 13:14:59 UTC
GCC 11 branch is being closed.
Comment 12 Richard Biener 2025-07-11 09:08:44 UTC
GCC 12 branch is being closed.