On 6/15/26 11:34 PM, Thomas Koenig wrote:
Hi Jerry,
This patch fixes a problem with nested DO_CONCURRENT loops. In short, shadow
variables were not unique between the nested levels.
Regression tested on x86_64.
OK for mainline?
I have a couple of questions.
+ int nunderscore = 1;
+ name = (char *) alloca (strlen (v->symtree->name) + 32);
This restricts the number of underscores to 32, and will break if there
are more. I would suggest declaring a static counter which adds the
number to a string, like n_vars in frontend-passes.cc , which is then
used in create_vars.
I have updated the patch, attached, to remove the limitation on underscores
and use a counter to generate unique names.
Regarding
+ name = (char *) alloca (GFC_MAX_SYMBOL_LEN + 1);
+ do
+ snprintf (name, GFC_MAX_SYMBOL_LEN + 1, "_%s_%d",
+ v->symtree->name, shadow_var_num++);
+ while (gfc_find_symtree (gfc_current_ns->sym_root, name) != NULL);
I still think that can overflow when the name comes close to
GFC_MAX_SYMBOL_LEN. Also, the do/while loop is not needed because
shadow_var_num should make things unique.
Regarding name: Not sure why alloca was used in the first place.
I think it would be better so use something like
char name[31]; /* 6 for shadow, 4 underscores, 10 for %d, 10 for %s,
1 for \0' */
snprintf (name, sizeof(name), "__shadow_%d_%10s", shadow_var_num)
Or make name longer so %s could hold the whole name of the gfc_symbol.
OK with a solution to the name length problem.
Best regards
Thomas
Lost track on this one.
Committed after fixing, regression testing .
Thanks Thomas
Regards,
Jerry
The master branch has been updated by Jerry DeLisle <[email protected]>:
https://gcc.gnu.org/g:9d448830cc85414e22839ac5be20c1ca1fd4ce33
commit r17-5265-g9d448830cc85414e22839ac5be20c1ca1fd4ce33
Author: Jerry DeLisle <[email protected]>
Date: Thu Jun 11 12:05:15 2026 -0700