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 c++/80920] New: warnings get position wrong - very confusing


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

            Bug ID: 80920
           Summary: warnings get position wrong - very confusing
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason.vas.dias at gmail dot com
  Target Milestone: ---

Attempts to compile the following demo code :
$ echo '
#include <initializer_list>
struct A
{ char _a[256];
  std::initializer_list<int> _al;
  A( std::initializer_list<int> l )
    : _a({0}),
      _al(l)
  {}      
};
' > b.C

produce the warning:

$ c++ -std=c++17 -Wall -Wextra -c b2.C
b.C: In constructor 'A::A(std::initializer_list<int>)':
b.C:7:12: warning: list-initializer for non-class type must not be
parenthesized
       _al(l)
            ^

This is very confusing, since the code that produces the warning is :
       _a({0})
             ^

Please could gcc point out the relevant element in the initializer list
that causes the problem, rather than the end of the initializer list, 
which makes it appear as if that line causes the problem .

Incidentally, why should it be illegal to specify an initializer for 
an array of non-class types ?  How else is one meant to ensure that
all elements of A::_a[] are initialized to zero ? Must one put :
   memset(_a, '\0', sizeof(_a))
inside the initializer - there is no other way ?

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