This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Kill 4 warnings, assert()


Bruno Haible <bruno@clisp.org> writes:

|> Jakub Jelinek wrote:
|> 
|> > --- libc/iconvdata/iso-2022-jp-3.c.jj   Mon Jul  1 12:31:43 2002
|> > +++ libc/iconvdata/iso-2022-jp-3.c      Mon Jul  1 13:53:09 2002
|> > @@ -109,9 +109,8 @@ enum
|> >                     {                                                         \
|> >                       /* Write out the shift sequence before the last         \
|> >                          character.  */                                       \
|> > -                     int set = data->__statep->__count & CURRENT_SEL_MASK;   \
|> > -                                                                             \
|> > -                     assert (set == JISX0208_1983_set);                      \
|> > +                     assert ((data->__statep->__count & CURRENT_SEL_MASK)    \
|> > +                             == JISX0208_1983_set);                          \
|> >                       *outbuf++ = ESC;                                        \
|> >                       *outbuf++ = '$';                                        \
|> >                       *outbuf++ = 'B';                                        \
|> 
|> 
|> The problem is not specific to iso-2022-jp-3.c, it appears often
|> anywhere 'assert' is used. The fix should be in the assert macro.
|> We can use 'sizeof' to avoid the "unused variable" warnings.

This is not compliant to the C standard:

    7.2[#1] The header <assert.h> defines the assert macro and refers to
    another macro,

              NDEBUG

    which is not defined by <assert.h>. If NDEBUG is defined as a macro
    name at the point in the source file where <assert.h> is included, the
    assert macro is defined simply as

             #define assert(ignore) ((void)0)

The use of sizeof can break strictly compliant code.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]