[Issue 23184] New: importC: array division with sizeof is problematic
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 13 21:58:41 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23184
Issue ID: 23184
Summary: importC: array division with sizeof is problematic
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ryuukk.dev at gmail.com
I have no clue how it is called, pardon my ignorance, but i came across that
snippet of code that is causing an issue:
```
static const char nk_utfmask[4 +1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
void test()
{
int a = (int)(sizeof(nk_utfmask)/sizeof(nk_utfmask)[0]);
}
```
it is the result of that macro: [1]
called here: [2]
using clang preprocessor the actual code:
```
static nk_rune
nk_utf_decode_byte(char c, int *i)
{
((i) ? (void)0 : __assert_func ("./nuklear_all.h", 7976, __func__, "i"));
if (!i) return 0;
for(*i = 0; *i < (int)(sizeof(nk_utfmask)/sizeof(nk_utfmask)[0]); ++(*i)) {
if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
return (nk_byte)(c & ~nk_utfmask[*i]);
}
return 0;
}
```
[1]
https://github.com/Immediate-Mode-UI/Nuklear/blob/11d8acfd4fbb9d0966161fa01d58be15be1974e3/src/nuklear.h#L5455
[2]
https://github.com/Immediate-Mode-UI/Nuklear/blob/11d8acfd4fbb9d0966161fa01d58be15be1974e3/src/nuklear_utf8.c#L30
--
More information about the Digitalmars-d-bugs
mailing list