This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/46313] [OOP] class container naming collisions


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46313

--- Comment #14 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2010-11-09 18:27:49 UTC ---
On Tue, Nov 09, 2010 at 05:59:17PM +0000, janus at gcc dot gnu.org wrote:
> 
> Index: gcc/fortran/class.c
> ===================================================================
> --- gcc/fortran/class.c (revision 166480)
> +++ gcc/fortran/class.c (working copy)
> @@ -117,7 +118,19 @@ get_unique_type_string (char *string, gfc_symbol *
>    if (derived->module)
>      sprintf (string, "%s_%s", derived->module, derived->name);
>    else
> -    sprintf (string, "%s_%s", derived->ns->proc_name->name, derived->name);
> +    {
> +      gfc_namespace *ns;
> +      char tmp[GFC_MAX_SYMBOL_LEN];

GFC_MAX_SYMBOL_LEN is 63.  Is this sufficient space?
Perhaps, snprintf() is needed to prevent buffer overflows
or use of alloca to dynamically size the buffer.  Oh,
the above declaration should probably have the '+1' for
the trailing '\0'.

> +      strcpy (&tmp[0], derived->name);
> +      /* Walk namespace hierarchy.  */
> +      for (ns = derived->ns; ns; ns = ns->parent)
> +       {
> +         sprintf (string, "%s_%s", ns->proc_name->name, tmp);

To solve Tobias' problem, use a capital 'M' (or other capital
letter) for '_'.  gfortran forces everything to lowercase, so
'M' can't appear in a symbol name.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]