[Bug debug/83935] DWARF for a variant part is incorrect

derodat at adacore dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 22 10:24:00 GMT 2018


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

--- Comment #2 from Pierre-Marie de Rodat <derodat at adacore dot com> ---
Thinking more about it, the rule that the discriminant entry must be a child of
the variant part entry sounds suspicious to me.

In the case of two variant parts, which are nested and depend on the same
discriminant, where should the discriminant entry go? If it’s in the outer one,
then it’s not a child of the nested one, violating the rule, and conversely. We
could duplicate the dicriminant entry, but that does not look friendly DWARF
consumer at all: two member entries would have the same name. And that sounds
like a waste of space. Here’s the Ada example:

   --  $ gcc -c -g -fgnat-encodings=minimal pck.ads).
   package Pck is

      type Rec (I : Integer) is record
         case I is
            when Positive =>
               C : Character;
               case I is
                  when 0 =>
                     null;
                  when others =>
                     N : Natural;
               end case;
            when others =>
               S : String (1 .. 10);
         end case;
      end record;

      R : Rec (1);

   end Pck;

And now, even though it’s illegal in Ada (it could be legal in another
language): what about two variant parts that have the same discriminant and
that are not nested?

I guess I should report these questions to the DWARF discussion mailing list.
What do you think, Tom?


More information about the Gcc-bugs mailing list