public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61312] New: variable function parameters declared as const in the class may not be declared as const in the function definition
@ 2014-05-25 22:41 alexis at m2osw dot com
  2014-05-25 22:46 ` [Bug c++/61312] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: alexis at m2osw dot com @ 2014-05-25 22:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61312
           Summary: variable function parameters declared as const in the
                    class may not be declared as const in the function
                    definition
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexis at m2osw dot com

In the following code, the functions test() and foo() are both declared with a
flags parameter which is marked const. The declaration of the actual functions
(blah::foo() and blah::test() below the class declaration) do not specify the
const modifier and yet the compiler does not complain.

This happens with any number of parameters in the function declarations. It
does not happen with complex types (other classes) only basic types like int.

Since I may want to overload such functions, it is a problem. ("int" and "int
const" are not supposed to be the same type.)


class blah
{
public:
    blah() {}

    void test(int const flags);

private:
    bool foo(int const flags);

    int     f_test;
};


bool blah::foo(int flags)
{
    if(flags & 0x10)
    {
        f_test = 3;
    }
    else
    {
        f_test = 1;
    }
    return (flags & 0x03) != 0;
}


void blah::test(int flags)
{
    flags |= 0x80;
    foo(flags | 0x10);
}


int main()
{
    blah a;
    a.test(3);
    return 0;
}


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

* [Bug c++/61312] variable function parameters declared as const in the class may not be declared as const in the function definition
  2014-05-25 22:41 [Bug c++/61312] New: variable function parameters declared as const in the class may not be declared as const in the function definition alexis at m2osw dot com
@ 2014-05-25 22:46 ` redi at gcc dot gnu.org
  2014-05-25 22:52 ` redi at gcc dot gnu.org
  2014-05-26  0:44 ` alexis at m2osw dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-25 22:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID
           Severity|major                       |normal

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, that's how C++ works. Top-level const qualifiers are not part of a
function signature.

This is not a bug, definitely not one with "major" severity!


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

* [Bug c++/61312] variable function parameters declared as const in the class may not be declared as const in the function definition
  2014-05-25 22:41 [Bug c++/61312] New: variable function parameters declared as const in the class may not be declared as const in the function definition alexis at m2osw dot com
  2014-05-25 22:46 ` [Bug c++/61312] " redi at gcc dot gnu.org
@ 2014-05-25 22:52 ` redi at gcc dot gnu.org
  2014-05-26  0:44 ` alexis at m2osw dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-25 22:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
http://www.dansaks.com/articles/2000-02%20Top-Level%20cv-Qualifiers%20in%20Function%20Parameters.pdf


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

* [Bug c++/61312] variable function parameters declared as const in the class may not be declared as const in the function definition
  2014-05-25 22:41 [Bug c++/61312] New: variable function parameters declared as const in the class may not be declared as const in the function definition alexis at m2osw dot com
  2014-05-25 22:46 ` [Bug c++/61312] " redi at gcc dot gnu.org
  2014-05-25 22:52 ` redi at gcc dot gnu.org
@ 2014-05-26  0:44 ` alexis at m2osw dot com
  2 siblings, 0 replies; 4+ messages in thread
From: alexis at m2osw dot com @ 2014-05-26  0:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Alexis Wilke <alexis at m2osw dot com> ---
Wow! I see that is now... "normal behavior". If you ask me, it sucks. But
well... I suppose I don't count.

Thank you for the PDF reference.


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

end of thread, other threads:[~2014-05-26  0:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-25 22:41 [Bug c++/61312] New: variable function parameters declared as const in the class may not be declared as const in the function definition alexis at m2osw dot com
2014-05-25 22:46 ` [Bug c++/61312] " redi at gcc dot gnu.org
2014-05-25 22:52 ` redi at gcc dot gnu.org
2014-05-26  0:44 ` alexis at m2osw 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).