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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
           Severity|normal                      |enhancement

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
This has changed in GCC 11 to print the following:

$ gcc -O2 -S -Wall pr72826.C
pr72826.C: In function ‘int main()’:
pr72826.C:8:13: warning: ‘*(unsigned char*)((char*)&timer +
offsetof(countdownTimer, countdownTimer::started))’ is used uninitialized
[-Wuninitialized]
    8 |         if (started) return;
      |             ^~~~~~~
pr72826.C:20:20: note: ‘*(unsigned char*)((char*)&timer +
offsetof(countdownTimer, countdownTimer::started))’ was declared here
   20 |     countdownTimer timer;
      |                    ^~~~~

So the internal details aren't leaking out into the message as much anymore. 
At the same time, there's quite a bit of unnecessary noise there that could be
further reduced.  The IL below doesn't show that there is enough information to
recover the original ‘countdownTimer::countdownTimer’ from the MEM_REF in the
read of timer$33:

int main ()
{
  unsigned char timer$33;
  bool _3;

  <bb 2> [local count: 1073741824]:
  _3 = VIEW_CONVERT_EXPR<bool>(timer$33_2(D));
  if (_3 != 0)
    goto <bb 5>; [51.12%]
  else
    goto <bb 3>; [48.88%]

The MEM_REF comes from the DECL_DEBUG_EXPR () for timer$33_2:

 <mem_ref 0x7fffea970c08
    type <integer_type 0x7fffea979c78 public unsigned QI
        size <integer_cst 0x7fffea7f7fc0 constant 8>
        unit-size <integer_cst 0x7fffea7f7fd8 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea979c78 precision:8 min <integer_cst 0x7fffea966c18 0> max <integer_cst
0x7fffea966798 255>>

    arg:0 <addr_expr 0x7fffea97a560
        type <pointer_type 0x7fffea96a498 type <record_type 0x7fffea96a348
countdownTimer>
            public unsigned DI
            size <integer_cst 0x7fffea7f7ed0 constant 64>
            unit-size <integer_cst 0x7fffea7f7ee8 constant 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea96a498>

        arg:0 <var_decl 0x7fffea977480 timer type <record_type 0x7fffea96a348
countdownTimer>
            used tree_1 tree_6 read decl_5 BLK /build/tmp/pr72826.C:20:20
            size <integer_cst 0x7fffea939c78 constant 272>
            unit-size <integer_cst 0x7fffea9667c8 constant 34>
            align:8 warn_if_not_align:0 context <function_decl 0x7fffea96e600
main>>>
    arg:1 <integer_cst 0x7fffea966cc0 type <pointer_type 0x7fffea96a498>
constant 33>>

This could be done by determining the member of the MEM_REF type at the offset.

But this would be just a minor cosmetic improvement.

Reply via email to