RE: [boost] Re: Re:Re: [static_assert] Regression with gcc 3.4.2?

Jonathan Turkanis <technews@kangaroologic.com> wrote:
"Robert Ramey" <ramey@rrsd.com> wrote in message news:20040919040443.D18A931132@acme.west.net...
"David B. Held" <dheld@codelogicconsulting.com> wrote in message news:cihmvu$3ik$1@sea.gmane.org...
#include <boost/static_assert.hpp>
template <typename T> struct foo { void bar(void) { BOOST_STATIC_ASSERT(false); } };
I use
.... BOOST_STATIC_ASSERT(sizeof(T) == 0);
The expression 'always_false<T>::value' can't be evaluated until the point of instantiation, since always_false could be specialized for T. OTOH, the compiler can tell immediately that 'sizeof(T) == 0' is false, so might it not replace 'sizeof(T) == 0' with 'false', and then issue the same error as in the quoted case?
sizeof(T) isn't always false, because for some types T it isn't even well-formed. As a value-dependent expression I think it must not be evaluated until the template is instantiated.

"Ben Hutchings" <ben.hutchings@businesswebsoftware.com> wrote in message news:A7F746377BDB7D4EA8E6623AF92F43C80C7DA6@copper.bwsint.com...
Jonathan Turkanis <technews@kangaroologic.com> wrote:
"Robert Ramey" <ramey@rrsd.com> wrote in message
I use
.... BOOST_STATIC_ASSERT(sizeof(T) == 0);
The expression 'always_false<T>::value' can't be evaluated until the point of instantiation, since always_false could be specialized for T. OTOH, the compiler can tell immediately that 'sizeof(T) == 0' is false, so might it not replace 'sizeof(T) == 0' with 'false', and then issue the same error as in the quoted case?
sizeof(T) isn't always false, because for some types T it isn't even well-formed.
Okay -- T could be a function type, for instance.
As a value-dependent expression I think it must not be evaluated until the template is instantiated.
At any rate, if 'sizeof(T) == 0' is not always false, then BOOST_STATIC_ASSERT(sizeof(T) == 0); is not a suitable generic replacement for BOOST_STATIC_ASSERT_FALSE(T). So I'm still in favor of adding BOOST_STATIC_ASSERT_FALSE. Jonathan
participants (2)
-
Ben Hutchings
-
Jonathan Turkanis