On 12/12/14 16:30, Patrick Baggett wrote:
On Fri, Dec 12, 2014 at 10:17 AM, Roland Scheidegger <srol...@vmware.com
<mailto:srol...@vmware.com>> wrote:
Am 12.12.2014 um 15:09 schrieb Jose Fonseca:
> From: José Fonseca <jfons...@vmware.com <mailto:jfons...@vmware.com>>
>
> f0ba7d897d1c22202531acb70f134f2edc30557d made debug_assert()/assert()
> unsafe for expressions, but only now with u_atomic.h started to
rely on
> them for Windows this became an issue.
>
> This fixes non-debug builds with MSVC.
> ---
> src/gallium/auxiliary/util/u_debug.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/util/u_debug.h
b/src/gallium/auxiliary/util/u_debug.h
> index badd5e2..4c22fdf 100644
> --- a/src/gallium/auxiliary/util/u_debug.h
> +++ b/src/gallium/auxiliary/util/u_debug.h
> @@ -185,7 +185,7 @@ void _debug_assert_fail(const char *expr,
> #ifdef DEBUG
> #define debug_assert(expr) ((expr) ? (void)0 :
_debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
> #else
> -#define debug_assert(expr) do { } while (0 && (expr))
> +#define debug_assert(expr) (void)(0 && (expr))
> #endif
>
>
>
Just for my own education, can someone explain what the need for
`debug_assert()` to have any expansion of `expr` at all? Rather, what
breaks with something like:
#define debug_assert(expr) ((void)0)
Did you read the above mentioned
f0ba7d897d1c22202531acb70f134f2edc30557d commit message? It's explained
there:
$ git show f0ba7d897d1c22202531acb70f134f2edc30557d
commit f0ba7d897d1c22202531acb70f134f2edc30557d
Author: Keith Whitwell <kei...@vmware.com>
Date: Mon Dec 28 11:05:06 2009 +0000
util: better fix for unused variable warnings with asserts
Modify the non-debug (ie disabled) version of assert to expose the
value in the expression to the compiler (avoiding the unused variable
messages) while still expanding to a noop.
diff --git a/src/gallium/auxiliary/util/u_debug.h
b/src/gallium/auxiliary/util/u_debug.h
index abd834c..facc30a 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -188,7 +188,7 @@ void _debug_assert_fail(const char *expr,
#ifdef DEBUG
#define debug_assert(expr) ((expr) ? (void)0 :
_debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
#else
-#define debug_assert(expr) ((void)0)
+#define debug_assert(expr) do { } while (0 && (expr))
#endif
Jose
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev