[php-src] Issue #14367: Build failure (incompatible pointer types, gcc-14) with PDO/iODBC

From: Date: Wed, 29 May 2024 19:57:12 +0000
Subject: [php-src] Issue #14367: Build failure (incompatible pointer types, gcc-14) with PDO/iODBC
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246984@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14367
Author: orlitzky

### Description

Originally reported at https://bugs.gentoo.org/932763
but I've confirmed with php-8.3.7:

```
/var/tmp/portage/dev-lang/php-8.3.6/work/sapis-build/embed/ext/pdo_odbc/odbc_driver.c: In function
‘pdo_odbc_error’:
/var/tmp/portage/dev-lang/php-8.3.6/work/sapis-build/embed/ext/pdo_odbc/odbc_driver.c:88:79: error:
passing argument 5 of ‘SQLGetDiagRec’ from incompatible pointer type
[-Wincompatible-pointer-types]
   88 |         rc = SQLGetDiagRec(htype, eh, recno++, (SQLCHAR *) einfo->last_state,
&einfo->last_error,
      |                                                                              
^~~~~~~~~~~~~~~~~~
      |                                                                               |
      |                                                                               SDWORD * {aka
long int *}
In file included from /usr/include/iodbc/sqlext.h:82,
                 from /usr/include/iodbc/sqlucode.h:81,
                 from
/var/tmp/portage/dev-lang/php-8.3.6/work/sapis-build/embed/ext/pdo_odbc/php_pdo_odbc_int.h:51,
                 from
/var/tmp/portage/dev-lang/php-8.3.6/work/sapis-build/embed/ext/pdo_odbc/odbc_driver.c:29:
/usr/include/iodbc/sql.h:1006:27: note: expected ‘SQLINTEGER *’ {aka ‘int *’} but argument
is of type ‘SDWORD *’ {aka ‘long int *’}
 1006 |     SQLINTEGER          * NativeError,
      |     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
```

Both unixODBC and iODBC typedef SQLINTEGER to either an int or a
long depending on the host system:

* https://github.com/lurcher/unixODBC/blob/master/include/sqltypes.h#L148
* https://github.com/openlink/iODBC/blob/develop/include/sqltypes.h#L120

Apparently the two libraries make different choices on my system, because building against unixODBC
still works, but in this case I don't think that's the root cause of the problem. If a
SQLINTEGER can be either int or long, and if the PHP
structure always has a fixed size SDWORD, there's probably a conversion or cast
that should be done on the PHP side.


### PHP Version

PHP 8.3.7

### Operating System

_No response_


Thread (1 message)

  • orlitzky
« previous php.bugs (#246984) next »