public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50034] New: Overload selection failure within class template
@ 2011-08-09 21:32 crowl at gcc dot gnu.org
  2011-08-12  4:50 ` [Bug c++/50034] [4.7 regression] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: crowl at gcc dot gnu.org @ 2011-08-09 21:32 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50034
           Summary: Overload selection failure within class template
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: crowl@gcc.gnu.org


The following code fails to compile with
g++ (GCC) 4.7.0 20110809 (experimental) [trunk revision 177606]

template <typename From, typename To>
class implicit {
 private:
 static From from_type();
 static char selector(To);
 static char (&selector(...))[2];
 public:
 static const bool value = sizeof(selector(implicit::from_type())) == 1;
};

template <typename From, typename To>
const bool implicit<From, To>::value;

class abstract {
 virtual void pure() = 0;
 abstract(const abstract&);
};

int main() {
 return implicit<const abstract&, long long int>::value;
}

# Note that I am not using C++0x.
g++ -c implicit.cc
implicit.cc: In instantiation of 'const bool implicit<const abstract&,
long long int>::value':
implicit.cc:20:54:   required from here
implicit.cc:16:3: error: 'abstract::abstract(const abstract&)' is private
implicit.cc:8:72: error: within this context
implicit.cc:8:72: error: cannot allocate an object of abstract type 'abstract'
implicit.cc:14:7: note:   because the following virtual functions are
pure within 'abstract':
implicit.cc:15:16: note:        virtual void abstract::pure()


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

* [Bug c++/50034] [4.7 regression] Overload selection failure within class template
  2011-08-09 21:32 [Bug c++/50034] New: Overload selection failure within class template crowl at gcc dot gnu.org
@ 2011-08-12  4:50 ` jason at gcc dot gnu.org
  2011-08-12 21:45 ` jason at gcc dot gnu.org
  2011-08-13  1:03 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-12  4:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2011-08-12
                 CC|jason at redhat dot com     |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1
            Summary|Overload selection failure  |[4.7 regression] Overload
                   |within class template       |selection failure within
                   |                            |class template
   Target Milestone|---                         |4.7.0

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-12 04:50:06 UTC ---
In this testcase, you're calling selector with an 'abstract' argument.  5.2.2/7
says,

The lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer
(4.3) standard conversions are performed on the argument expression.

4.1/2 says,

When an lvalue-to-rvalue conversion occurs in an unevaluated operand or a
subexpression thereof (Clause 5) the value contained in the referenced object
is not accessed. Otherwise, if the glvalue has a class type, the conversion
copy-initializes a temporary of type T from the glvalue and the result of the
conversion is a prvalue for the temporary.

Hmm, having different semantics for lvalue-rvalue conversion depending on
whether the expression is evaluated is surprising, but that does seem to be
what the standard says.  Alrighty then.


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

* [Bug c++/50034] [4.7 regression] Overload selection failure within class template
  2011-08-09 21:32 [Bug c++/50034] New: Overload selection failure within class template crowl at gcc dot gnu.org
  2011-08-12  4:50 ` [Bug c++/50034] [4.7 regression] " jason at gcc dot gnu.org
@ 2011-08-12 21:45 ` jason at gcc dot gnu.org
  2011-08-13  1:03 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-12 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-12 21:28:01 UTC ---
Author: jason
Date: Fri Aug 12 21:27:52 2011
New Revision: 177722

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177722
Log:
    PR c++/50034
    * call.c (convert_arg_to_ellipsis): force_rvalue only in
    potentially evaluated context.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/defaulted28.C


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

* [Bug c++/50034] [4.7 regression] Overload selection failure within class template
  2011-08-09 21:32 [Bug c++/50034] New: Overload selection failure within class template crowl at gcc dot gnu.org
  2011-08-12  4:50 ` [Bug c++/50034] [4.7 regression] " jason at gcc dot gnu.org
  2011-08-12 21:45 ` jason at gcc dot gnu.org
@ 2011-08-13  1:03 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-13  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Depends on|                            |49102
         Resolution|                            |FIXED

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-13 00:00:39 UTC ---
Fixed.


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

end of thread, other threads:[~2011-08-13  0:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-09 21:32 [Bug c++/50034] New: Overload selection failure within class template crowl at gcc dot gnu.org
2011-08-12  4:50 ` [Bug c++/50034] [4.7 regression] " jason at gcc dot gnu.org
2011-08-12 21:45 ` jason at gcc dot gnu.org
2011-08-13  1:03 ` jason 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).