public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37806]  New: CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
@ 2008-10-11 19:51 andrew at nelless dot net
  2008-10-11 20:00 ` [Bug c++/37806] " rguenth at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: andrew at nelless dot net @ 2008-10-11 19:51 UTC (permalink / raw)
  To: gcc-bugs

[-- 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


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

end of thread, other threads:[~2010-01-08  3:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-11 19:51 [Bug c++/37806] New: CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope andrew at nelless dot net
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

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).