public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57211] New: wrong line indicated in warning for synthesized method
@ 2013-05-08 13:08 doko at gcc dot gnu.org
  2013-05-15  5:38 ` [Bug c++/57211] " anthony.foiani at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: doko at gcc dot gnu.org @ 2013-05-08 13:08 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57211

             Bug #: 57211
           Summary: wrong line indicated in warning for synthesized method
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: doko@gcc.gnu.org


seen at least in 4.6, 4.7, 4.8 and trunk:

$ g++-4.8 -c -std=c++11 -Wunused-parameter  test.cpp
test.cpp:3:8: warning: unused parameter 'p' [-Wunused-parameter]
 struct A  // line pointed-to by warning
        ^
test.cpp: In function 'int main()':
test.cpp:21:11: note: synthesized method 'A& A::operator=(A&&)' first required
here 
         b = std::move(a);
           ^

$ cat test.cpp 
#include <functional>

struct A  // line pointed-to by warning
{
        struct B
        {
                B& operator=(B&&) { return *this; }
        };

        B f;

        A() = default;
        A& operator=(A&& p) = default;  // where the method is declared
};

int main()
{
        A a;
        A b;

        b = std::move(a);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/57211] wrong line indicated in warning for synthesized method
  2013-05-08 13:08 [Bug c++/57211] New: wrong line indicated in warning for synthesized method doko at gcc dot gnu.org
@ 2013-05-15  5:38 ` anthony.foiani at gmail dot com
  2013-05-15  5:40 ` anthony.foiani at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: anthony.foiani at gmail dot com @ 2013-05-15  5:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57211

Anthony Foiani <anthony.foiani at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anthony.foiani at gmail dot com

--- Comment #1 from Anthony Foiani <anthony.foiani at gmail dot com> ---
Created attachment 30117
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30117&action=edit
demonstration code showing problem and workaround


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/57211] wrong line indicated in warning for synthesized method
  2013-05-08 13:08 [Bug c++/57211] New: wrong line indicated in warning for synthesized method doko at gcc dot gnu.org
  2013-05-15  5:38 ` [Bug c++/57211] " anthony.foiani at gmail dot com
@ 2013-05-15  5:40 ` anthony.foiani at gmail dot com
  2013-05-22  1:11 ` paolo.carlini at oracle dot com
  2013-05-22  9:34 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: anthony.foiani at gmail dot com @ 2013-05-15  5:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57211

--- Comment #2 from Anthony Foiani <anthony.foiani at gmail dot com> ---
I'm also seeing this bug, in version 4.7.2.

Instead of trying to fix the line offset, I believe the right thing is to not
emit this warning in this case at all.

The parameter is certainly used, even if the synthesized method uses a
different formal argument name.  (In which case, shouldn't it offer a
corresponding undeclared variable error?)

Put another way: if the method has a signature which can be defaulted, then the
parameter name(s) should be ignored.  (IMHO of course.)

A workaround is to omit the parameter name, but I feel that reduces
readability.  (It also makes some documentation-generating tools sad, e.g.,
doxygen.)

See attached for a version of Matthias's code that shows workaround via macro
flag.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/57211] wrong line indicated in warning for synthesized method
  2013-05-08 13:08 [Bug c++/57211] New: wrong line indicated in warning for synthesized method doko at gcc dot gnu.org
  2013-05-15  5:38 ` [Bug c++/57211] " anthony.foiani at gmail dot com
  2013-05-15  5:40 ` anthony.foiani at gmail dot com
@ 2013-05-22  1:11 ` paolo.carlini at oracle dot com
  2013-05-22  9:34 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-22  1:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57211

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-05-22
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/57211] wrong line indicated in warning for synthesized method
  2013-05-08 13:08 [Bug c++/57211] New: wrong line indicated in warning for synthesized method doko at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-05-22  1:11 ` paolo.carlini at oracle dot com
@ 2013-05-22  9:34 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-22  9:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57211

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.0.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-22  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-08 13:08 [Bug c++/57211] New: wrong line indicated in warning for synthesized method doko at gcc dot gnu.org
2013-05-15  5:38 ` [Bug c++/57211] " anthony.foiani at gmail dot com
2013-05-15  5:40 ` anthony.foiani at gmail dot com
2013-05-22  1:11 ` paolo.carlini at oracle dot com
2013-05-22  9:34 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).