On Friday, January 24, 2003, at 09:36  PM, David Abrahams wrote:

Howard Hinnant <[EMAIL PROTECTED]> writes:

Fortunately circumstances such as the one illustrated
above seem to be rare (at least in my experience).  But
it is amusing (amazing?) how many traits like tests are
today passing non-POD classes to an ellipsis, and
invoking undefined behavior! :-)
I thought there wansn't any undefined behavior there, because none of
the traits actually generate or execute the code within sizeof().  I
can understand it being unspecified whether you get an error due to
accessibility of the c-ctor.  Am I misunderstanding how the standard
works in this area?
Expressions in sizeof are accessed checked:

class B
{
int foo();
};

int main()
{
B b;
unsigned i = sizeof(b.foo()); // error, foo() not accessible
}

Furthermore, it is undefined to pass a non-pod to an ellipse (5.2.2/7):

int foo(...);

class B
{
public:
B();
private:
B(const B&);
};

int main()
{
foo(B()); // undefined behavior
}

If you stick that in a sizeof, it is still undefined:

sizeof(foo(B()));

If you overload foo, it is still undefined:

int foo(...);
char foo(int);

At least, that is my current understanding.

Note that I am not saying that traits using ellipses are not a good thing. I'm just exposing a non-portable corner.

-Howard

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to