This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/68179] New: No warning when specifying a Default_Component_Value on derived type, resulting in unexpected behavior


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

            Bug ID: 68179
           Summary: No warning when specifying a Default_Component_Value
                    on derived type, resulting in unexpected behavior
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at gyw dot com
  Target Milestone: ---

Created attachment 36634
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36634&action=edit
Sample code to demonstrate dangerous behavior

The 'Default_Component_Value' aspect is not allowed on derived types, yet there
is no warning from the compiler when it is used. The aspect is just silently
ignored.

As it stands, one can declare a type derived from String or another array type,
and specify a 'Default_Component_Value' for it. However, the default value
isn't applied to the components, and there is no warning.

It is inconsistent that one can specify a 'Default_Value' on a derived type,
but not a 'Default_Component_Value' on a derived array type. 

I found a mention that allowing default values for components could be risky
because of potentially different sizes for the components. It isn't clear to me
how this could occur, but the rule is there.

I find that silently ignoring the 'Default_Component_Value' aspect is
potentially dangerous, as the program's behavior thus differs from what is the
intent of the programmer. Subsequent code review is also bound to miss an error
of this nature.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]