Skip to content

Commit d6f86ca

Browse files
committed
Fix release build failure
GCC complained about potentially uninitialized __orig_bailout, even though the variable has an initializer. This warning was quite persistent, I was only able to avoid it by using a separate function. Am I missing something?
1 parent 9e22c3d commit d6f86ca

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,15 @@ static void preload_check_windows_restrictions(zend_class_entry *scope) {
38703870
}
38713871
#endif
38723872

3873+
static inline int preload_update_class_constants(zend_class_entry *ce) {
3874+
/* This is a separate function to work around what appears to be a bug in GCC
3875+
* maybe-uninitialized analysis. */
3876+
zend_try {
3877+
return zend_update_class_constants(ce);
3878+
} zend_end_try();
3879+
return FAILURE;
3880+
}
3881+
38733882
static zend_class_entry *preload_load_prop_type(zend_property_info *prop, zend_string *name) {
38743883
zend_class_entry *ce;
38753884
if (zend_string_equals_literal_ci(name, "self")) {
@@ -3915,18 +3924,7 @@ static void preload_ensure_classes_loadable() {
39153924
#endif
39163925

39173926
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
3918-
int result = SUCCESS;
3919-
zend_try {
3920-
result = zend_update_class_constants(ce);
3921-
} zend_catch {
3922-
/* Provide some context for the generated error. */
3923-
zend_error_noreturn(E_ERROR,
3924-
"Error generated while resolving initializers of class %s during preloading",
3925-
ZSTR_VAL(ce->name));
3926-
} zend_end_try();
3927-
if (result == FAILURE) {
3928-
/* Just present to be safe: We generally always throw some
3929-
* other fatal error as part of update_class_constants(). */
3927+
if (preload_update_class_constants(ce) == FAILURE) {
39303928
zend_error_noreturn(E_ERROR,
39313929
"Failed to resolve initializers of class %s during preloading",
39323930
ZSTR_VAL(ce->name));

ext/opcache/tests/preload_004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ var_dump(class_exists('Foo'));
1414
--EXPECTF--
1515
Fatal error: Undefined class constant 'self::DOES_NOT_EXIST' in Unknown on line 0
1616

17-
Fatal error: Error generated while resolving initializers of class Foo during preloading in Unknown on line 0
17+
Fatal error: Failed to resolve initializers of class Foo during preloading in Unknown on line 0

ext/opcache/tests/preload_loadable_classes_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Warning: Use of undefined constant UNDEF - assumed 'UNDEF' (this will throw an E
1414

1515
Fatal error: Class 'Foo' not found in Unknown on line 0
1616

17-
Fatal error: Error generated while resolving initializers of class Test during preloading in Unknown on line 0
17+
Fatal error: Failed to resolve initializers of class Test during preloading in Unknown on line 0

0 commit comments

Comments
 (0)