public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "andrew at nelless dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/37806]  New: CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
Date: Sat, 11 Oct 2008 19:51:00 -0000	[thread overview]
Message-ID: <bug-37806-16821@http.gcc.gnu.org/bugzilla/> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2061 bytes --]

Hi,

First of all this is my first bug report to GNU GCC so please bare with me.

The issue I having is with typedef assisted declarations of class/struct member
functions. It seems to me that cv-qualifiers on function typedef's are treated
inconsistantly depending on the scope of the typedef.

The below code demonstrates the problem: with NS_SCOPE defined the code
compiles fine with "-Wall -Wextra -pedantic" on 4.3.2 but when NS_SCOPE is
undefined, the const qualifier is ignored with "error: ignoring ‘const’
qualifiers added to function type". To me this seems completely inconsistent
and there is no explaination as to why the qualifer is ignored.

---snip---
#include <iostream>

#ifdef NS_SCOPE
typedef void (function_type)(int) const;
#endif

template <typename T>
struct S1
{
    #ifndef NS_SCOPE
    typedef void (function_type)(int) const;
    #endif  
};


struct S2: public S1<int>
{
    virtual function_type f = 0;
};


struct S3: public S2
{
    void 
    f (int i) const
    {
        std::cout << "Hello world: " << i << std::endl;
    }
};


int
main()
{
    S3 s;
    s.f(5);
}
---snip---


I did find a C++ defect report that may be relevent, but to be honest, i'm not 
certain what is going on with regard to the standard here

http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#295

I hope this can be resolved because it will allow for some really groovy
template
generated interfaces.

Visual Studio 2005 (the only other compiler I have to hand) seems to compile
this
code without NS_SCOPE defined, but I'm uncertain how to thoroughly test this
there.


-- 
           Summary: CV-qualifiers on function typedef's are inconsistently
                    accepted depending on typedef scope
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew at nelless dot net
  GCC host triplet: x86_64


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


             reply	other threads:[~2008-10-11 19:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-11 19:51 andrew at nelless dot net [this message]
2008-10-11 20:00 ` [Bug c++/37806] " rguenth at gcc dot gnu dot org
2008-10-13 23:01 ` pinskia at gcc dot gnu dot org
2009-03-02  1:21 ` jason at gcc dot gnu dot org
2009-03-02  1:22 ` jason at gcc dot gnu dot org
2009-03-31 18:32 ` jason at gcc dot gnu dot org
2009-03-31 18:38 ` jason at gcc dot gnu dot org
2009-04-07  4:38 ` jason at gcc dot gnu dot org
2009-04-07  4:39 ` jason at gcc dot gnu dot org
2010-01-08  3:45 ` pinskia at gcc dot gnu dot org

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-37806-16821@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).