public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rutsky.vladimir at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64431] New: "-Wignored-qualifiers" warning gives misleading position in code
Date: Sun, 28 Dec 2014 22:02:00 -0000	[thread overview]
Message-ID: <bug-64431-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 64431
           Summary: "-Wignored-qualifiers" warning gives misleading
                    position in code
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rutsky.vladimir at gmail dot com

"type qualifiers ignored on function return type" warning doesn't point in
"const" that is being ignored, but instead it points to function arguments or
function qualifiers.

Consider following example:

$ cat ignored_qualifiers.cpp
struct C
{
    const int f1();
    const int f2(float);
    const int f3(char *, int);
    const int f4() volatile const;
    const int f5() const volatile;
};

const int f6();
const int f7(float);
const int f8(char *, int);


$ g++-4.9 -c -Wignored-qualifiers ignored_qualifiers.cpp
ignored_qualifiers.cpp:3:18: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f1();
                  ^
ignored_qualifiers.cpp:4:23: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f2(float);
                       ^
ignored_qualifiers.cpp:5:29: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f3(char *, int);
                             ^
ignored_qualifiers.cpp:6:29: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f4() volatile const;
                             ^
ignored_qualifiers.cpp:7:26: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f5() const volatile;
                          ^
ignored_qualifiers.cpp:10:14: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
 const int f6();
              ^
ignored_qualifiers.cpp:11:19: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
 const int f7(float);
                   ^
ignored_qualifiers.cpp:12:25: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
 const int f8(char *, int);
                         ^


Expected behavior: the warning should point on "const" in the return value of a
funtion.
For example:


ignored_qualifiers.cpp:7:26: warning: type qualifiers ignored on function
return type [-Wignored-qualifiers]
     const int f5() const volatile;
     ^



$ g++-4.9 --version
g++-4.9 (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


             reply	other threads:[~2014-12-28 22:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-28 22:02 rutsky.vladimir at gmail dot com [this message]
2014-12-28 22:04 ` [Bug c++/64431] " rutsky.vladimir at gmail dot com
2014-12-29  1:50 ` manu at gcc dot gnu.org
2015-01-31  1:10 ` eugene.zelenko at gmail dot com
2015-03-05  9:40 ` paolo.carlini at oracle dot com
2015-03-05 17:51 ` paolo.carlini at oracle dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64431-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).