This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/56041] New: Constexpr conversion function definition not found in template argument context


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

             Bug #: 56041
           Summary: Constexpr conversion function definition not found in
                    template argument context
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: webrown.cpp@gmail.com


Created attachment 29215
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29215
C++11 metaprogramming experiment

Enclosed code fails to compile, but should.

Tested with:
  g++-mp-4.7 (MacPorts gcc47 4.7.2_2) 4.7.2
  g++-mp-4.8 (MacPorts gcc48 4.8-20130113_0) 4.8.0 20130113 (experimental)

Compiled via:
  g++-mp-4.7 -O3 -std=c++0x main.cc
  g++-mp-4.8 -O3 -std=c++0x main.cc

Use of expression true_type{} as template argument corresponding to bool
template parameter produces diagnostic:
  'constexpr integral_constant<T, v>::operator T() const [with T = bool; T v =
true]' used before its definition

[The syntax variant true_type() [note parentheses instead of braces as shown
above] is correctly diagnosed, applying 14.3/2.  This variant, as well as a
C++03-style variant, are present but commented out in the attachment; I left
them for possible additional experimentation.]

Using braces should force interpretation as an expression, not a type.  That
expression should result in a default-constructed temporary object of the named
type; that type, defined earlier in the source, has a conversion operator
defined inline.  However, the compiler claims that the operator's definition is
not yet defined at the point of (implicit) use.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]