title: libc6: comma operator in assert macro definition
body: <p>My system uses libc6 2.29. In <code>/usr/include/assert.h</code> I can find the definition of <code>assert()</code> macro:</p>
  
  <pre><code>/* The first occurrence of EXPR is not evaluated due to the sizeof,
     but will trigger any pedantic warnings masked by the __extension__
     for the second occurrence.  The ternary operator is required to
     support function pointers and bit fields in this context, and to
     suppress the evaluation of variable length arrays.  */
  #  define assert(expr)                          \
    ((void) sizeof ((expr) ? 1 : 0), __extension__ ({         \
        if (expr)                             \
          ; /* empty */                           \
        else                              \
          __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);   \
      }))
  </code></pre>
  
  <p>I wonder why to use the comma operator, and what is meant by '<code>The first occurrence of EXPR is not evaluated due to the sizeof</code>'.</p>
  
  <p>What problem there would be using the following definition:</p>
  
  <pre><code>#  define assert(expr)                      \
    ({                                        \
        if (expr)                             \
             ; /* empty */                            \
        else                              \
             __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);    \
      })
  </code></pre>
  
  <p>Edit:</p>
  
  <p>what value does the operator ({ }) get if <code>expr</code> is true?</p>
  
  <p>Is it possible to rewrite the definition of assert() as follows?</p>
  
  <pre><code>#  define assert(expr)                          \
    ((void) sizeof ((expr) ? 1 : 0), __extension__ ({         \
        if (!expr)                                \
            __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \
      }))
  </code></pre>
  
  <p>Where are the problems with this last definition?</p>