tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: databases/sqlite on powerpc

Am 24.06.2022 um 01:29 schrieb David Holland:
On Thu, Jun 23, 2022 at 03:51:31PM +0200, Havard Eidnes wrote:
  > it seems I've come across a compiler bug on NetBSD/powerpc
  > -current;

Nope, it's UB in the source :-(

Are you sure about the UB? C11 and C11 6.5p4 say it's mostly
implementation-defined behavior, and GCC says at that it
treats the sign bit as just another value bit.

I played around a bit with Godbolt's Compiler Explorer but couldn't
reproduce any differences between the signed and unsigned versions of a
simplified example code.

int arraysize;
int types[400];

int hash_signed(int h) {
    int t1 = h & 0x7fffffff;
    return t1 % arraysize;

int type_signed(int h) {
    int t1 = h & 0x7fffffff;
    return types[t1 % arraysize];

int type_unsigned(int h) {
    int t1 = (unsigned)h & 0x7fffffff;
    return types[t1 % arraysize];

C11 6.5p4 says "have implementation-defined and undefined aspects",
without giving further details. There could indeed be undefined
behavior, but from GCC's documentation I wouldn't think so.


Home | Main Index | Thread Index | Old Index