[Bug ada/87170] New: compiler complains about not referenced character literals if they are only used in string literals

ievgenii.meshcheriakov at here dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 31 14:07:00 GMT 2018


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

            Bug ID: 87170
           Summary: compiler complains about not referenced character
                    literals if they are only used in string literals
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ievgenii.meshcheriakov at here dot com
  Target Milestone: ---

Created attachment 44637
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44637&action=edit
Example file demonstrating the bug

Gnat generates warnings about unused character literals when they are only used
in string literal like demonstrated in the attached simplified example.

The type Bit values are only used inside definition of Bits. The compiler
generates the following warnings:

  % gnatchop bug.ada
  splitting bug.ada into:
     bug.ads
     bug.adb
  % gnatmake -gnatwa bug.adb
  x86_64-linux-gnu-gcc-8 -c -gnatwa bug.adb
  bug.adb:3:17: warning: literal "'0'" is not referenced
  bug.adb:3:22: warning: literal "'1'" is not referenced

While values of Bit are not used directly they are still used in the definition
of Bits, so the warning should not be generated.

The warning is not generated when definitions are changed as follows:

  type Bit is (Zero, One);
  ...
  constant Bits : constant Bit_Array := (Zero, One);


More information about the Gcc-bugs mailing list