[Bug target/124877] [16 Regression] wrong code passing 225 literal to unsigned char argument since r16-170
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 14 08:57:54 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124877
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
That was changed with r16-169-g78db4753c9646a.
The following fixes it:
diff --git a/gcc/calls.cc b/gcc/calls.cc
index 337e01065c2..8ac780f640e 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -1391,7 +1391,7 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
for (argpos = 0; argpos < num_actuals; i--, argpos++)
{
tree type = TREE_TYPE (args[i].tree_value);
- int unsignedp;
+ int unsignedp = TYPE_UNSIGNED (type);
/* Replace erroneous argument with constant zero. */
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
@@ -1405,7 +1405,10 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
we would pass the first field of the union or record. We have
already verified that the modes are the same. */
if (RECORD_OR_UNION_TYPE_P (type) && TYPE_TRANSPARENT_AGGR (type))
- type = TREE_TYPE (first_field (type));
+ {
+ type = TREE_TYPE (first_field (type));
+ unsignedp = TYPE_UNSIGNED (type);
+ }
/* Decide where to pass this arg.
@@ -1473,6 +1476,7 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
args[i].tree_value = build_fold_addr_expr_loc (loc,
args[i].tree_value);
type = TREE_TYPE (args[i].tree_value);
+ unsignedp = TYPE_UNSIGNED (type);
if (*ecf_flags & ECF_CONST)
*ecf_flags &= ~(ECF_CONST | ECF_LOOPING_CONST_OR_PURE);
@@ -1532,6 +1536,7 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
args[i].tree_value
= build_fold_addr_expr_loc (loc, make_tree (type, copy));
type = TREE_TYPE (args[i].tree_value);
+ unsignedp = TYPE_UNSIGNED (type);
*may_tailcall = false;
maybe_complain_about_tail_call (exp,
_("argument must be passed"
@@ -1540,7 +1545,6 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
arg.pass_by_reference = true;
}
- unsignedp = TYPE_UNSIGNED (type);
arg.type = type;
arg.mode
= promote_function_mode (type, TYPE_MODE (type), &unsignedp,
More information about the Gcc-bugs
mailing list