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

            Bug ID: 68425
           Summary: Enhanced error message when an array is initialized
                    with too many elements
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: morwenn29 at hotmail dot fr
  Target Milestone: ---

The current error message when trying to initialize a fixed-size C array with
too many elements (with both gcc and g++):

    error: too many initializers for 'const int [2]'
        const int array[2] = { 1, 2, 3 };

When there are many elements, it is sometimes interesting to know whether we
initialized the array with too many or not enough elements. I would expect such
a message instead:

    error: too many initializers for 'const int [2]' (3 elements, expected 2)
        const int array[2] = { 1, 2, 3 };

I guess that it is rather cheap to implement and can help to diagnose the
actual problem faster.

Reply via email to