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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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 ` rguenth at gcc dot gnu dot org
  2008-10-13 23:01 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-11 20:00 UTC (permalink / raw)
  To: gcc-bugs

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



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-10-11 19:58 -------
EDG accepts the code.  With GCC 4.3 and newer we reject the code with

t.C: In function ‘int main()’:
t.C:32: error: cannot declare variable ‘s’ to be of abstract type ‘S3’
t.C:21: note:   because the following virtual functions are pure within ‘S3’:
t.C:16: note:   virtual void S2::f(int)

GCC 4.2 has this in addition to the CV error.  Of course the reason is the
same.

GCC never accepted the code, so this is not a regression.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-11 19:58:47
               date|                            |


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-13 23:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-10-13 22:59 -------
Related to PR 29993 where we rejected this code before because of the const.  I
want to say that even though we handle them now, we don't handle them fully
now.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |29993


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-02  1:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jason at gcc dot gnu dot org  2009-03-02 01:20 -------
My patch for 39310 also fixes this bug.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |39310
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-10-11 19:58:47         |2009-03-02 01:20:48
               date|                            |


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-02  1:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2009-03-02 01:22 -------
*** Bug 39321 has been marked as a duplicate of this bug. ***


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu dot org


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-31 18:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2009-03-31 18:31 -------
Subject: Bug 37806

Author: jason
Date: Tue Mar 31 18:31:17 2009
New Revision: 145365

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145365
Log:
        PR c++/37806
        * typeck.c (cp_apply_type_quals_to_decl): Don't apply any quals
        to a typedef.
        * tree.c (cp_build_qualified_type_real): Don't apply restrict to a
        function type.
        * decl.h (enum decl_context): Add TEMPLATE_TYPE_ARG.
        * decl.c (groktypename): Add is_template_arg parameter.
        (grokdeclarator): Allow function cv-quals on a template type arg.
        * parser.c (cp_parser_new_type_id, cp_parser_type_id): Add
        is_template_arg argument in calls to groktypename.
        * cp-tree.h: Adjust prototype.
        * error.c (dump_type_prefix, dump_type_suffix): Fix plain
        FUNCTION_TYPE printing.

        PR libstdc++/39310
        * include/tr1_impl/type_traits (is_function): Add partial
        specializations with function cv-quals.
        (__is_function_helper): Remove.
        (is_member_pointer): Don't define in terms of is_member_*_pointer.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl.h
    trunk/gcc/cp/error.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/tree.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/g++.dg/template/qualttp20.C
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr1_impl/type_traits


-- 


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (4 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-31 18:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2009-03-31 18:38 -------
Subject: Bug 37806

Author: jason
Date: Tue Mar 31 18:37:49 2009
New Revision: 145366

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145366
Log:
        PR c++/37806
        * g++.dg/template/typedef17.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/typedef17.C
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (5 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-07  4:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2009-04-07 04:38 -------
Subject: Bug 37806

Author: jason
Date: Tue Apr  7 04:38:10 2009
New Revision: 145648

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145648
Log:
        * decl.c (grokdeclarator): Reject pointer to qualified function
        type.

        PR c++/37806, core issue 547
        * typeck.c (cp_apply_type_quals_to_decl): Don't apply any quals
        to a typedef.
        * tree.c (cp_build_qualified_type_real): Don't apply restrict to a
        function type.
        * decl.h (enum decl_context): Add TEMPLATE_TYPE_ARG.
        * decl.c (groktypename): Add is_template_arg parameter.
        (grokdeclarator): Allow function cv-quals on a template type arg.
        * parser.c (cp_parser_new_type_id, cp_parser_type_id): Add
        is_template_arg argument in calls to groktypename.
        * cp-tree.h: Adjust prototype.
        * error.c (dump_type_prefix, dump_type_suffix): Fix plain
        FUNCTION_TYPE printing.

        PR libstdc++/39310
        * include/tr1_impl/type_traits (is_function): Add partial
        specializations with function cv-quals.
        (__is_function_helper): Remove.
        (is_member_pointer): Don't define in terms of is_member_*_pointer.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/typedef2.C
      - copied unchanged from r145367,
trunk/gcc/testsuite/g++.dg/other/typedef2.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef17.C
      - copied unchanged from r145367,
trunk/gcc/testsuite/g++.dg/template/typedef17.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/cp-tree.h
    branches/gcc-4_4-branch/gcc/cp/decl.c
    branches/gcc-4_4-branch/gcc/cp/decl.h
    branches/gcc-4_4-branch/gcc/cp/error.c
    branches/gcc-4_4-branch/gcc/cp/parser.c
    branches/gcc-4_4-branch/gcc/cp/tree.c
    branches/gcc-4_4-branch/gcc/cp/typeck.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/qualttp20.C
    branches/gcc-4_4-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_4-branch/libstdc++-v3/include/tr1_impl/type_traits


-- 


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-07  4:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2009-04-07 04:38 -------
Fixed for 4.4.


-- 

jason at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/37806] CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope
  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
                   ` (7 preceding siblings ...)
  2009-04-07  4:39 ` jason at gcc dot gnu dot org
@ 2010-01-08  3:45 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-01-08  3:45 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.0


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