Skip to content

Commit 3655158

Browse files
committed
Fix phpGH-17687: initializer-string for array of ... warnings
Starting with gcc 15 the warning `-Wunterminated-string-initialization` is enabled by default. We make now use of the `nonstring` attribute to silence the warning for the cases where this is intended. This is targeted to 8.3 because of the people who compile with -Werror.
1 parent 41e11a6 commit 3655158

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

Zend/zend_portability.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,12 @@ extern "C++" {
737737
# define ZEND_INDIRECT_RETURN
738738
#endif
739739

740+
#if __has_attribute(nonstring)
741+
# define ZEND_NONSTRING __attribute__((nonstring))
742+
#else
743+
# define ZEND_NONSTRING
744+
#endif
745+
740746
#define __ZEND_DO_PRAGMA(x) _Pragma(#x)
741747
#define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
742748
#if defined(__clang__)

ext/pdo/pdo_sqlstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "php_pdo_driver.h"
2626

2727
struct pdo_sqlstate_info {
28-
const char state[5];
28+
const char state[5] ZEND_NONSTRING;
2929
const char *desc;
3030
};
3131

ext/standard/crypt_sha256.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static const char sha256_rounds_prefix[] = "rounds=";
318318
#define ROUNDS_MAX 999999999
319319

320320
/* Table with characters for base64 transformation. */
321-
static const char b64t[64] =
321+
static const char b64t[64] ZEND_NONSTRING =
322322
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
323323

324324
char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen)

ext/standard/crypt_sha512.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static const char sha512_rounds_prefix[] = "rounds=";
351351
#define ROUNDS_MAX 999999999
352352

353353
/* Table with characters for base64 transformation. */
354-
static const char b64t[64] =
354+
static const char b64t[64] ZEND_NONSTRING =
355355
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
356356

357357

0 commit comments

Comments
 (0)