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++/43064] improve location and text of diagnostics in constructor initializer lists


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2010-02-14 19:44:58         |2018-2-21
            Summary|improve location and text   |improve location and text
                   |of Wconversion warning for  |of diagnostics in
                   |initializer list            |constructor initializer
                   |                            |lists
           Severity|enhancement                 |normal

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This applies to all diagnostics, not just -Wconversion:

class X {
    X() : bad(1),
    good(1)
    { }

    void* bad;
    int good;
};

i.cc: In constructor ‘X::X()’:
i.cc:3:11: error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive]
     good(1)
           ^

As Manu said, it's unlikely that the member name can be printed easily, because
the code that checks the initialization works with types, and the name of the
variable isn't known at that point. There are also dozens of different errors
and warnings that can happen there (not just -Wconversion) so they would all
need to be updated.

If the location was correct and shown with a range marking the variable that
would remove the need for printing the name:

i.cc: In constructor ‘X::X()’:
i.cc:2:11: error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive]
     X() : bad(1),
           ^~~~~~

I'm changing the priority from enhancement to normal, because printing the
wrong location is a bug.

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