bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Bjarni Ingi Gislason <bjarniig@simnet.is>
Subject: Re: -funsigned-char
Date: Wed, 08 Feb 2023 01:21:43 +0100	[thread overview]
Message-ID: <3741171.Sf62SLZxhT@nimes> (raw)
In-Reply-To: <Y+LZ6hsjn2ZPN6tu@localhost>

Bjarni Ingi Gislason wrote:
> > ../../gnulib-tests/test-localeconv.c:53: assertion 'l->frac_digits == CHAR_MAX' failed
> > FAIL test-localeconv (exit status: 134)
> > 
> 
> l->frac_digits is 127 and  CHAR_MAX is 255.
> 
>   This is due to the CFLAG "-funsigned-char"

When you connect a libc compiled for one ABI and a program compiled for a
different ABI (that's what -funsigned-char produces), you evidently get
breakage.

>   which I always use having
> compiled "less", which produced a lot of warnings without this flag.

The way to fix the problems occurring because a program wants to view
their strings as 'unsigned char *' is
  - NOT to use -funsigned-char, as you just have seen,
  - NOT to cast pointers from 'char *' to 'unsigned char *' and vice
    versa, because ultimately this leads to strict aliasing violations
    in some places,
  - BUT to cast individual 'char *' elements to 'unsigned char' right
    after fetching them from the string. E.g.
       if (isalnum ((unsigned char) *p))

Bruno





      reply	other threads:[~2023-02-08  0:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06  1:17 FAIL in diffutils/gnulib-tests Bjarni Ingi Gislason
2023-02-06  1:28 ` Bruno Haible
2023-02-06  3:19   ` Bjarni Ingi Gislason
2023-02-06 18:28     ` Bruno Haible
2023-02-07 23:08 ` Bjarni Ingi Gislason
2023-02-08  0:21   ` Bruno Haible [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3741171.Sf62SLZxhT@nimes \
    --to=bruno@clisp.org \
    --cc=bjarniig@simnet.is \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).