mwild1 / luadbi

Multi-backend SQL database library for Lua
MIT License
38 stars 14 forks source link

GCC 14: error: assignment to ‘my_bool *’ {aka ‘char *’} from incompatible pointer type ‘int *’ [-Wincompatible-pointer-types] #72

Open robert-scheck opened 5 months ago

robert-scheck commented 5 months ago

Trying to build LuaDBI 0.7.2 on Fedora Rawhide using GCC 14 fails like this (report from Fedora mass rebuild):

gcc -c -o build/dbd_mysql_statement.o dbd/mysql/statement.c -I/usr/include -g -pedantic -Wall -O2 -shared -fPIC -DPIC -std=c99 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I. -shared -Wl,-z,relro -Wl,--as-needed   -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient
dbd/mysql/statement.c: In function ‘statement_execute’:
dbd/mysql/statement.c:221:33: error: assignment to ‘my_bool *’ {aka ‘char *’} from incompatible pointer type ‘int *’ [-Wincompatible-pointer-types]
  221 |                 bind[i].is_null = (int*)1;
      |                                 ^
dbd/mysql/statement.c:230:33: error: assignment to ‘my_bool *’ {aka ‘char *’} from incompatible pointer type ‘int *’ [-Wincompatible-pointer-types]
  230 |                 bind[i].is_null = (int*)0;
      |                                 ^
dbd/mysql/statement.c:245:33: error: assignment to ‘my_bool *’ {aka ‘char *’} from incompatible pointer type ‘int *’ [-Wincompatible-pointer-types]
  245 |                 bind[i].is_null = (int*)0;
      |                                 ^
dbd/mysql/statement.c:256:33: error: assignment to ‘my_bool *’ {aka ‘char *’} from incompatible pointer type ‘int *’ [-Wincompatible-pointer-types]
  256 |                 bind[i].is_null = (int*)0;
      |                                 ^
make: *** [Makefile:82: build/dbd_mysql_statement.o] Error 1

Because of commit e951acfb0adf385a1cdf6d2a4b68435d62510a2b, only 3 not 4 occurrences exist in current code in Git.

sparked435 commented 4 months ago

Weird thing is, MySQL docs explicitly say to do this.

Pullrequest #75 includes a fix. I am uncertain if it will work with MySQL 8 as they've changed the name from 'my_bool' to 'bool'.

robert-scheck commented 4 months ago

Fedora builds against MariaDB Connector/C, not MySQL directly.

sparked435 commented 4 months ago

Fedora builds against MariaDB Connector/C, not MySQL directly.

LuaDBI currently supports both MySQL and MariaDB - and one pointer cast is not enough to justify forking the driver. I'm forced to keep both in mind at all times.

robert-scheck commented 4 months ago

I'm sorry, this was meant as information only, given you referred to MySQL 8 specifically. But sounds like some #ifdef or so is maybe needed?

sparked435 commented 4 months ago

I don't think an ifdef is needed - Finally got hold of a MySQL 8.0.36 system to test #75 with and it compiled without any warnings.

I think that resolves this issue, okay to close?

robert-scheck commented 4 months ago

In general yes. May I ask how far we are from a LuaDBI release? So is it worth to backport or is a release just around the corner?

sparked435 commented 4 months ago

I'd like some more feedback that the merged pull request resolved the original problem. That's the only thing stopping me from a release at this time. If I don't hear anything soon I will likely release it anyway.

robert-scheck commented 3 months ago

@sparked435, I am sorry, but building v0.7.3 fails on Intel/AMD 32 bit like this now (other architectures are building fine):

gcc -c -o build/dbd_mysql_statement.o dbd/mysql/statement.c -I/usr/include -g -pedantic -Wall -O2 -shared -fPIC -DPIC -std=c99 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -I. -shared -Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient
dbd/mysql/statement.c: In function ‘statement_execute’:
dbd/mysql/statement.c:271:40: error: assignment to ‘long unsigned int *’ from incompatible pointer type ‘size_t *’ {aka ‘unsigned int *’} [-Wincompatible-pointer-types]
  271 |                         bind[i].length = str_len;
      |                                        ^
make: *** [Makefile:82: build/dbd_mysql_statement.o] Error 1