public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype
@ 2012-03-16  2:45 hstong at ca dot ibm.com
  2012-03-16  9:55 ` [Bug c++/52597] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hstong at ca dot ibm.com @ 2012-03-16  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52597
           Summary: [C++11] missing diagnostics for invalid use of
                    non-static member function in decltype
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hstong@ca.ibm.com
              Host: powerpc64-unknown-linux-gnu
            Target: powerpc64-unknown-linux-gnu


The following test case shows that GCC allows several ill-formed decltype
constructs with non-static member functions.

Using the last form, SFINAE can be put into play--so wrong overload resolution
and partial specialization matching can be made to occur.

In particular:

bar0 violates N3290 subclause 5.1.1 [expr.prim.general] paragraph 12 regarding
valid uses of an id-expression that denotes a non-static data member or non-
static member function.

The other decltype specifiers violate N3290 subclause 5.2.5 [expr.ref]
paragraph 4 since the non-static member function is not used as the left-hand
operand of a member function call.


### Self-contained source:$ cat illdclty.cc
struct A {
   int zip();

   decltype(zip) bar0;  // invalid use of non-static member function name
      // [expr.prim.general]
   void bar1() {   typedef decltype(this->A::zip) x;   }
      // invalid use of non-static member function name
      // [expr.ref]
   void bar2() {   typedef decltype(A::zip) x;   }
      // invalid use of non-static member function name
      // (same as bar1), see [class.mfct.non-static]
};

typedef decltype(A().zip) x;
      // invalid use of non-static member function name
      // [expr.ref]


### Compiler invocation:$ g++-4.6.0 --std=c++0x illdclty.cc -W -Wall -pedantic
-c


### Compiler output:
(return code 0)


### g++ -v output:$ g++-4.6.0 -v
Using built-in specs.
COLLECT_GCC=g++-4.6.0
COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.0
--disable-libssp --disable-libgcj --enable-version-specific-runtime-libs
--with-cpu=default32 --enable-secureplt --with-long-double-128 --enable-shared
--enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++,fortran
--with-gmp=/usr/local
Thread model: posix
gcc version 4.6.0 (GCC)


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

* [Bug c++/52597] [C++11] missing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
@ 2012-03-16  9:55 ` redi at gcc dot gnu.org
  2012-03-29  1:05 ` hstong at ca dot ibm.com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-16  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-16 08:59:29 UTC ---
With 4.7.0 you get

t.cc:4:16: error: decltype cannot resolve address of overloaded function
t.cc: In member function ‘void A::bar1()’:
t.cc:6:49: error: decltype cannot resolve address of overloaded function
t.cc:6:52: error: invalid type in declaration before ‘;’ token
t.cc: In member function ‘void A::bar2()’:
t.cc:9:43: error: decltype cannot resolve address of overloaded function
t.cc:9:46: error: invalid type in declaration before ‘;’ token
t.cc: At global scope:
t.cc:14:25: error: decltype cannot resolve address of overloaded function
t.cc:14:28: error: invalid type in declaration before ‘;’ token


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

* [Bug c++/52597] [C++11] missing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
  2012-03-16  9:55 ` [Bug c++/52597] " redi at gcc dot gnu.org
@ 2012-03-29  1:05 ` hstong at ca dot ibm.com
  2012-08-24 11:53 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hstong at ca dot ibm.com @ 2012-03-29  1:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Hubert Tong <hstong at ca dot ibm.com> 2012-03-28 23:51:37 UTC ---
The message from 4.7.0 does not really make sense, although it probably does
fix the functional issues associated with the reported bug in contexts where
SFINAE applies.


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

* [Bug c++/52597] [C++11] missing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
  2012-03-16  9:55 ` [Bug c++/52597] " redi at gcc dot gnu.org
  2012-03-29  1:05 ` hstong at ca dot ibm.com
@ 2012-08-24 11:53 ` redi at gcc dot gnu.org
  2012-08-24 12:43 ` hstong at ca dot ibm.com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-24 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-24 11:53:19 UTC ---
As the testcase is rejected by 4,7 and trunk, can we close this?


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

* [Bug c++/52597] [C++11] missing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
                   ` (2 preceding siblings ...)
  2012-08-24 11:53 ` redi at gcc dot gnu.org
@ 2012-08-24 12:43 ` hstong at ca dot ibm.com
  2012-08-24 14:07 ` [Bug c++/52597] [C++11] confusing " redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hstong at ca dot ibm.com @ 2012-08-24 12:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Hubert Tong <hstong at ca dot ibm.com> 2012-08-24 12:42:58 UTC ---
I find the message to be confusing.


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

* [Bug c++/52597] [C++11] confusing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
                   ` (3 preceding siblings ...)
  2012-08-24 12:43 ` hstong at ca dot ibm.com
@ 2012-08-24 14:07 ` redi at gcc dot gnu.org
  2013-03-27 10:06 ` paolo.carlini at oracle dot com
  2020-04-27  8:26 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-08-24 14:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid,            |diagnostic
                   |rejects-valid, wrong-code   |
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-08-24
            Version|4.6.0                       |4.7.1
            Summary|[C++11] missing diagnostics |[C++11] confusing
                   |for invalid use of          |diagnostics for invalid use
                   |non-static member function  |of non-static member
                   |in decltype                 |function in decltype
     Ever Confirmed|0                           |1
      Known to fail|4.3.2, 4.4.0, 4.5.0, 4.6.0  |

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-24 14:06:45 UTC ---
OK, let's change it from an accepts-invalid with 4.6 to a diagnostic issue with
4.7


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

* [Bug c++/52597] [C++11] confusing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
                   ` (4 preceding siblings ...)
  2012-08-24 14:07 ` [Bug c++/52597] [C++11] confusing " redi at gcc dot gnu.org
@ 2013-03-27 10:06 ` paolo.carlini at oracle dot com
  2020-04-27  8:26 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-27 10:06 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-27 10:06:30 UTC ---
Fixed for 4.9.


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

* [Bug c++/52597] [C++11] confusing diagnostics for invalid use of non-static member function in decltype
  2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
                   ` (5 preceding siblings ...)
  2013-03-27 10:06 ` paolo.carlini at oracle dot com
@ 2020-04-27  8:26 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-27  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed by r197131

    re PR c++/52597 ([C++11] confusing diagnostics for invalid use of
non-static member function in decltype)

        PR c++/52597
        * typeck.c (invalid_nonstatic_memfn_p): Use get_first_fn.  Take tree.
        * semantics.c (finish_decltype_type): Check it before type_unknown_p.
        * cp-tree.h: Adjust prototype.

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

end of thread, other threads:[~2020-04-27  8:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-16  2:45 [Bug c++/52597] New: [C++11] missing diagnostics for invalid use of non-static member function in decltype hstong at ca dot ibm.com
2012-03-16  9:55 ` [Bug c++/52597] " redi at gcc dot gnu.org
2012-03-29  1:05 ` hstong at ca dot ibm.com
2012-08-24 11:53 ` redi at gcc dot gnu.org
2012-08-24 12:43 ` hstong at ca dot ibm.com
2012-08-24 14:07 ` [Bug c++/52597] [C++11] confusing " redi at gcc dot gnu.org
2013-03-27 10:06 ` paolo.carlini at oracle dot com
2020-04-27  8:26 ` redi at gcc dot gnu.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).