Title
Conditionally-supported behavior for non-POD objects passed to ellipsis redux
Status
cd1
Section
7.6.1.3 [expr.call]
Submitter
Howard Hinnant

Created on 2007-06-06.00:00:00 last changed 196 months ago

Messages

Date: 2008-09-15.00:00:00

[Voted into the WP at the September, 2008 meeting.]

Date: 2007-09-15.00:00:00

Proposed resolution (September, 2007):

Change 7.6.1.3 [expr.call] paragraph 7 as follows:

...Passing an a potentially-evaluated argument of non-trivial class type (Clause 11 [class]) with no corresponding parameter is conditionally-supported, with implementation-defined semantics...
Date: 2007-07-15.00:00:00

Notes from the July, 2007 meeting:

The CWG agreed with the suggestion to allow such calls in unevaluated contexts.

Date: 2007-08-05.00:00:00

Issue 506 changed passing a non-POD class type to an ellipsis from undefined behavior to conditionally-supported behavior. As a result, an implementation could conceivably reject code like the following:

    struct two {char _[2];};

    template <class From, class To>
    struct is_convertible
    {
    private:
            static From f;

            template <class U> static char test(const U&);
            template <class U> static two test(...);
    public:
            static const bool value = sizeof(test<To>(f)) == 1;
    };

    struct A
    {
         A();
    };

    int main()
    {
         const bool b = is_convertible<A,int>::value;  // b == false
    }

This technique has become popular in template metaprogramming, and no non-POD object is actually passed at runtime. Concepts will eliminate much (perhaps not all) of the need for this kind of programming, but legacy code will persist.

Perhaps this technique should be officially supported by allowing implementations to reject passing a non-POD type to ellipsis only if it appears in a potentially-evaluated expression?

History
Date User Action Args
2008-10-05 00:00:00adminsetmessages: + msg1809
2008-10-05 00:00:00adminsetstatus: ready -> cd1
2008-06-29 00:00:00adminsetstatus: review -> ready
2008-05-18 00:00:00adminsetmessages: + msg1651
2008-05-18 00:00:00adminsetstatus: drafting -> review
2007-08-05 00:00:00adminsetmessages: + msg1519
2007-08-05 00:00:00adminsetstatus: open -> drafting
2007-06-06 00:00:00admincreate