Discussion:
[PATCH 2/2] ctype: Avoid GCC note in towctrans_l.c
Sebastian Huber
2018-07-27 07:37:45 UTC
Permalink
The previous version genenerated the following GCC note:

towctrans_l.c:44:1: note: offset of packed bit-field 'diff' has changed in GCC 4.4
caseconv_table [] = {
^~~~~~~~~~~~~~

Signed-off-by: Sebastian Huber <***@embedded-brains.de>
---
newlib/libc/ctype/towctrans_l.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index 7b8a23c9c..b829266a4 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -37,8 +37,8 @@ enum {TO1, TOLO, TOUP, TOBOTH};
enum {EVENCAP, ODDCAP};
static struct caseconv_entry {
uint_least32_t first: 21;
- uint_least8_t diff: 8;
- uint_least8_t mode: 2;
+ uint_least32_t diff: 8;
+ uint_least32_t mode: 2;
int_least32_t delta: 17;
} __attribute__ ((packed))
caseconv_table [] = {
--
2.13.7
Andre Vieira (lists)
2018-07-27 10:43:57 UTC
Permalink
Post by Sebastian Huber
towctrans_l.c:44:1: note: offset of packed bit-field 'diff' has changed in GCC 4.4
caseconv_table [] = {
^~~~~~~~~~~~~~
---
newlib/libc/ctype/towctrans_l.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index 7b8a23c9c..b829266a4 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -37,8 +37,8 @@ enum {TO1, TOLO, TOUP, TOBOTH};
enum {EVENCAP, ODDCAP};
static struct caseconv_entry {
uint_least32_t first: 21;
- uint_least8_t diff: 8;
- uint_least8_t mode: 2;
+ uint_least32_t diff: 8;
+ uint_least32_t mode: 2;
int_least32_t delta: 17;
} __attribute__ ((packed))
caseconv_table [] = {
That fixes it, thanks Sebastian!

Cheers,
Andre
Sebastian Huber
2018-08-01 08:54:55 UTC
Permalink
Hello Andre,
Post by Andre Vieira (lists)
Post by Sebastian Huber
towctrans_l.c:44:1: note: offset of packed bit-field 'diff' has changed in GCC 4.4
caseconv_table [] = {
^~~~~~~~~~~~~~
---
newlib/libc/ctype/towctrans_l.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index 7b8a23c9c..b829266a4 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -37,8 +37,8 @@ enum {TO1, TOLO, TOUP, TOBOTH};
enum {EVENCAP, ODDCAP};
static struct caseconv_entry {
uint_least32_t first: 21;
- uint_least8_t diff: 8;
- uint_least8_t mode: 2;
+ uint_least32_t diff: 8;
+ uint_least32_t mode: 2;
int_least32_t delta: 17;
} __attribute__ ((packed))
caseconv_table [] = {
That fixes it, thanks Sebastian!
would you mind testing Newlib 6158b30e3e9b1b582ae60b15d64e775fa1705483.
It includes a fix for this bug, some FreeBSD compatibility changes in
<sys/cdefs.h> and a new configuration option for all targets
newlib/configure.host. Maybe we can use this commit for a new snapshot.
The broken ctype support in the latest snapshot introduced by me is not
really great.
--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : ***@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Corinna Vinschen
2018-07-30 07:34:11 UTC
Permalink
The commit 46ba1675c457324b0eeef4670a09101ef3f34c50 accidently changed a
bit-field from signed to unsigned. The caseconv_entry::delta must be a
signed integer, see also "newlib/libc/ctype/caseconv.t".
Unfortunately, a standard GCC/Newlib build is done without
-Wsign-conversion. Using this warning option would have helped to avoid
caseconv.t:2:22: warning: unsigned conversion from 'int' to 'unsigned int:17' changes value from '-32' to '131040' [-Wsign-conversion]
{0x0061, 25, TOUP, -32},
---
newlib/libc/ctype/towctrans_l.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index 42085ac78..7b8a23c9c 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -39,7 +39,7 @@ static struct caseconv_entry {
uint_least32_t first: 21;
uint_least8_t diff: 8;
uint_least8_t mode: 2;
- uint_least32_t delta: 17;
+ int_least32_t delta: 17;
} __attribute__ ((packed))
caseconv_table [] = {
#include "caseconv.t"
--
2.13.7
Thanks, please apply series.


Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
Loading...