Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15041
| Path | csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Eduardo A. Bustamante López <dualbus@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | [PATCH 3/3] Fix incompatible pointer type warning in unicode.c |
| Date | Fri, 4 Jan 2019 12:25:42 -0800 |
| Lines | 57 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.6776.1546633582.1284.bug-bash@gnu.org> (permalink) |
| References | <20190104202542.4626-1-dualbus@gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | usenet.stanford.edu 1546633582 18515 208.118.235.17 (4 Jan 2019 20:26:22 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | Eduardo A. Bustamante López <dualbus@gmail.com> |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FtvBQAT04IqYTejkXUGCXmzRIgESki9z8xr/cRPCLRQ=; b=omD09FOFvEdg14FUWnPSY6ephSZNZymGDjfr66/bfcBz+wTKkKHsHcAD6RBBRhIWvv YdZgQ3lrOHw1JyGxOsQpyJp9nMygqe9MncEsn3cWXVhCCkRDElP4Ayno0nNYtOc0E9dp o/KqOgxEhy5NuBqp2v1AThOgb/AvaZnqehT6kri/mlKN5tf5w5SS2DNjW40kHSe/1THe rsTGRTxcnotgCyeqoTbSmf2J8+7NEGKGJxIPv7OOYsfzk60cGobLdBOyPJ3L9FoNxamE xqHGSIjukPWrTflG5repsBTrVXccFJ63OAArwoLHrMg4Cp/SdBrOWwYeDPm+y20iI/Yo 0Mrg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FtvBQAT04IqYTejkXUGCXmzRIgESki9z8xr/cRPCLRQ=; b=Sl43lG0GU7Ekd2+XxU7P99O56WBtjDqd4/25vuHXSqdRHVgqwFhCWIQ0pSlFQDPCFm fY4nPNaaPnTyoB3p0BEEo040DrEsTatljrZslHIQuu4TEe4hu3zF9miQ8KF4vZDHMTdF mhjNeDq00WF/bamUnlF9Mmd3MogHK2xMVmP+CEKYNhLxth2YsrtJ+N7nCfBYo1Sd8a5X zGfeo8WFAj7OfWt2ClSWhi4ILguP4sdk794e4egorsBlbZdNbYwXcoTCfGdjz9xbhY8e G3JsZUWr8vFUzdR72q7Lzt742piPiNdIRKToRdaZVttirSj+RbAsGp4vNJ+1hqxuJvbm 84GA== |
| X-Gm-Message-State | AJcUukcJ/7F20ioCYCM3yNaUmBLartkflh0as0rXfw3LRqc+/VDkZgbI TjWSzg6lVL8hQN9hoLFIX1tLzXPB |
| X-Google-Smtp-Source | ALg8bN4wm+t22at5G9BM6Dknb4JTkRqd4q9O30tLJT/OREvZEhFg2xUTMRZQSUFDETth1vzRzU+O7Q== |
| X-Received | by 2002:a17:902:8c91:: with SMTP id t17mr4629727plo.119.1546633577317; Fri, 04 Jan 2019 12:26:17 -0800 (PST) |
| X-Mailer | git-send-email 2.20.1 |
| In-Reply-To | <20190104202542.4626-1-dualbus@gmail.com> |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:4864:20::641 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash/> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:15041 |
Show key headers only | View raw
The warning is raised by Clang (7.0.1-4) when sizeof(wchar_t) is 4
| dualbus@system76-pc:~/src/gnu/bash/lib/sh$ make unicode.o
| clang -c -I. -I../.. -I../.. -I../../lib -I../../include -I. -DHAVE_CONFIG_H -DSHELL -ggdb -O0 -Wno-parentheses -Wno-format-security unicode.c
| unicode.c:262:69: warning: incompatible pointer types passing 'wchar_t [3]' to parameter of type 'unsigned short *' [-Wincompatible-pointer-types]
| else if (sizeof (wchar_t) == 2 && c <= 0x10ffff && u32toutf16 (c, ws))
| ^~
| 1 warning generated.
dualbus@system76-pc:~/src/gnu/bash$ clang -v 2>&1 | head -n2
clang version 7.0.1-4 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu
In practice, this isn't really a problem because the compiler should optimize
away the `sizeof(wchar_t) == 2' branch. Still, it's easy to fix.
I think that maybe there should be some sort of compile-time assertion inside
`u32toutf16`, to ensure it's only used when `sizeof(wchar_t) == 2', but I don't
know how to do that.
---
lib/sh/unicode.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c
index fe13c4a0..99c422ab 100644
--- a/lib/sh/unicode.c
+++ b/lib/sh/unicode.c
@@ -216,21 +216,21 @@ u32toutf8 (wc, s)
int
u32toutf16 (c, s)
u_bits32_t c;
- unsigned short *s;
+ wchar_t *s;
{
int l;
l = 0;
if (c < 0x0d800 || (c >= 0x0e000 && c <= 0x0ffff))
{
- s[0] = (unsigned short) (c & 0xFFFF);
+ s[0] = (wchar_t) (c & 0xFFFF);
l = 1;
}
else if (c >= 0x10000 && c <= 0x010ffff)
{
c -= 0x010000;
- s[0] = (unsigned short)((c >> 10) + 0xd800);
- s[1] = (unsigned short)((c & 0x3ff) + 0xdc00);
+ s[0] = (wchar_t)((c >> 10) + 0xd800);
+ s[1] = (wchar_t)((c & 0x3ff) + 0xdc00);
l = 2;
}
s[l] = 0;
--
2.20.1
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
[PATCH 3/3] Fix incompatible pointer type warning in unicode.c Eduardo A. Bustamante López <dualbus@gmail.com> - 2019-01-04 12:25 -0800
csiph-web