Title
Trait precondition violations
Status
resolved
Section
[meta.type.synop]
Submitter
Russia

Created on 2016-11-09.00:00:00, last changed 2018-11-12.04:30:58.

Messages

Date: 2018-11-12.04:30:58

Proposed resolution:

This wording is relative to N4606.

  1. Add a new paragraph after [meta.unary.prop] paragraph 3:

    -?- If an instantiation of any template declared in this subclause fails to meet the preconditions, the program is ill-formed.

  2. Change the specification for alignment_of in Table 39 in [meta.unary.prop.query]:

    Table 39 — Type property queries
    template <class T> struct alignment_of; alignof(T).
    Requires: alignof(T) shall be a valid expression (5.3.6), otherwise the program is ill-formed
  3. Change the specification for is_base_of, is_convertible, is_callable, and is_nothrow_callable in Table 40 in [meta.rel]:

    Table 40 — Type relationship predicates
    […]
    template <class Base, class
    Derived>
    struct is_base_of;
    […] If Base and Derived are
    non-union class types and are
    different types (ignoring possible
    cv-qualifiers) then Derived shall
    be a complete type, otherwise the program is ill-formed.
    [Note: Base classes that
    are private, protected, or ambiguous are,
    nonetheless, base classes. — end note]
    template <class From, class To>
    struct is_convertible;
    see below From and To shall be complete
    types, arrays of unknown bound,
    or (possibly cv-qualified) void
    types, otherwise the program is
    ill-formed
    .
    template <class Fn, class...
    ArgTypes, class R>
    struct is_callable<
    Fn(ArgTypes...), R>;
    […] Fn, R, and all types in the
    parameter pack ArgTypes shall
    be complete types, (possibly
    cv-qualified) void, or arrays of
    unknown bound,
    otherwise the program is ill-formed
    .
    template <class Fn, class...
    ArgTypes, class R>
    struct is_nothrow_callable<
    Fn(ArgTypes...), R>;
    […] Fn, R, and all types in the
    parameter pack ArgTypes shall
    be complete types, (possibly
    cv-qualified) void, or arrays of
    unknown bound,
    otherwise the program is ill-formed
    .
  4. Add a new paragraph after [meta.trans] paragraph 2:

    -2- Each of the templates in this subclause shall be a TransformationTrait (20.15.1).

    -?- If an instantiation of any template declared in this subclause fails to meet the Requires: preconditions, the program is ill-formed.

Date: 2018-11-11.00:00:00

[ 2018-11-11 Resolved by P1285R0, adopted in San Diego. ]

Date: 2018-08-22.12:55:05

[ 2018-08 Batavia Monday issue discussion ]

Issues 2797, 2939, 3022, and 3099 are all closely related. Walter to write a paper resolving them.

Date: 2017-06-15.00:00:00

[ 2017-06-15 request from Daniel ]

I don't believe that this should be "Ready"; I added the extra note to LWG 2797 *and* added the new issue 2939 exactly to *prevent* 2797 being accepted for C++17

Setting status back to 'Open'

Date: 2017-03-15.00:00:00

[ 2017-03-03, Kona Friday morning ]

Unanimous consent to adopt this for C++17, but due to a misunderstanding, it wasn't on the ballot

Setting status to 'Ready' so we'll get it in immediately post-C++17

Date: 2017-03-15.00:00:00

[ 2017-03-02, Daniel comments ]

LWG 2939 has been created to signal that some of our current type trait constraints are not quite correct and I recommend not to enforce the required diagnostics for traits that are sensitive to mismatches of the current approximate rules.

Date: 2017-02-02.00:41:18

[ Issues Telecon 16-Dec-2016 ]

Priority 2

Date: 2016-11-15.00:00:00

[ 2016-11-09, Jonathan provides wording ]

Date: 2016-11-09.00:00:00

Addresses RU 2

Failed prerequirement for the type trait must result in ill-formed program. Otherwise hard detectable errors will happen:

#include <type_traits>

struct foo;

void damage_type_trait() {
  // must be ill-formed
  std::is_constructible<foo, foo>::value;
}

struct foo{};

int main() {
  static_assert(
    // produces invalid result
    std::is_constructible<foo, foo>::value,
    "foo must be constructible from foo"
  );
}

Suggested resolution:

Add to the end of the [meta.type.synop] section:

Program is ill-formed if precondition for the type trait is violated.

History
Date User Action Args
2018-11-12 04:30:58adminsetmessages: + msg10173
2018-11-12 04:30:58adminsetstatus: open -> resolved
2018-08-22 12:55:05adminsetmessages: + msg10092
2017-06-16 04:45:38adminsetmessages: + msg9269
2017-06-16 04:45:38adminsetstatus: ready -> open
2017-06-02 05:40:10adminsetmessages: + msg9192
2017-06-02 05:40:10adminsetstatus: new -> ready
2017-03-02 19:30:15adminsetmessages: + msg9043
2016-12-16 20:56:38adminsetmessages: + msg8727
2016-11-09 22:52:41adminsetmessages: + msg8604
2016-11-09 22:52:41adminsetmessages: + msg8603
2016-11-09 00:00:00admincreate