Re: com php-src: Assert that EMPTY_SWITCH_DEFAULT_CASE() cannot be reached in debug: Zend/zend.h Zend/zend_operators.c

From: Date: Fri, 23 May 2014 12:18:41 +0000
Subject: Re: com php-src: Assert that EMPTY_SWITCH_DEFAULT_CASE() cannot be reached in debug: Zend/zend.h Zend/zend_operators.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-78505@lists.php.net to get a copy of this message
Hi Nikita, ext/pcntl/tests/002.phpt started to fail after some of your recent changes. could you please take a look. It doesn't allow me to run the full test suite. Thanks. Dmitry. On Thu, May 22, 2014 at 9:00 PM, Nikita Popov <nikic@php.net> wrote: > Commit: 6f0f8511f2023142feba12a0633912c9dcd3d292 > Author: Nikita Popov <nikic@php.net> Fri, 16 May 2014 18:54:01 > +0200 > Parents: 94d092dea3b31c2fb6157d3137a3c4792a2980f3 > Branches: phpng > > Link: > > http://git.php.net/?p=php-src.git;a=commitdiff;h=6f0f8511f2023142feba12a0633912c9dcd3d292 > > Log: > Assert that EMPTY_SWITCH_DEFAULT_CASE() cannot be reached in debug > > Changed paths: > M Zend/zend.h > M Zend/zend_operators.c > > > Diff: > diff --git a/Zend/zend.h b/Zend/zend.h > index 2780181..1968d76 100644 > --- a/Zend/zend.h > +++ b/Zend/zend.h > @@ -52,15 +52,14 @@ > # define ZEND_PATHS_SEPARATOR ':' > #endif > > -#ifdef ZEND_WIN32 > /* Only use this macro if you know for sure that all of the switches > values > are covered by its case statements */ > -#define EMPTY_SWITCH_DEFAULT_CASE() \ > - default: \ > - __assume(0); \ > - break; > +#if ZEND_DEBUG > +# define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_ASSERT(0); break; > +#elif defined(ZEND_WIN32) > +# define EMPTY_SWITCH_DEFAULT_CASE() default: __assume(0); break; > #else > -#define EMPTY_SWITCH_DEFAULT_CASE() > +# define EMPTY_SWITCH_DEFAULT_CASE() > #endif > > /* all HAVE_XXX test have to be after the include of zend_config above */ > diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c > index 9e68df0..5fb88b1 100644 > --- a/Zend/zend_operators.c > +++ b/Zend/zend_operators.c > @@ -431,11 +431,7 @@ ZEND_API void convert_to_long_base(zval *op, int > base) /* {{{ */ > } > return; > } > - default: > - zend_error(E_WARNING, "Cannot convert to ordinal > value"); > - zval_dtor(op); > - ZVAL_LONG(op, 0); > - break; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -493,11 +489,7 @@ ZEND_API void convert_to_double(zval *op) /* {{{ */ > } > break; > } > - default: > - zend_error(E_WARNING, "Cannot convert to real > value (type=%d)", Z_TYPE_P(op)); > - zval_dtor(op); > - ZVAL_DOUBLE(op, 0); > - break; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -580,10 +572,7 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */ > } > break; > } > - default: > - zval_dtor(op); > - ZVAL_BOOL(op, 0); > - break; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -650,10 +639,7 @@ ZEND_API void _convert_to_string(zval *op > ZEND_FILE_LINE_DC) /* {{{ */ > } > break; > } > - default: > - zval_dtor(op); > - ZVAL_BOOL(op, 0); > - break; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -833,9 +819,7 @@ try_again: > case IS_REFERENCE: > op = Z_REFVAL_P(op); > goto try_again; > - default: > - zend_error(E_WARNING, "Cannot convert to ordinal > value"); > - return 0; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -875,9 +859,7 @@ try_again: > case IS_REFERENCE: > op = Z_REFVAL_P(op); > goto try_again; > - default: > - zend_error(E_WARNING, "Cannot convert to real > value (type=%d)", Z_TYPE_P(op)); > - return 0.0; > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > @@ -934,9 +916,7 @@ try_again: > case IS_REFERENCE: > op = Z_REFVAL_P(op); > goto try_again; > - default: > - //??? original code returns bool(0) > - return STR_EMPTY_ALLOC(); > + EMPTY_SWITCH_DEFAULT_CASE() > } > } > /* }}} */ > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.cvs (#78505) next »