On Tue, 9 Nov 2010 at 11:41, Janus Weil <ja...@gcc.gnu.org> wrote:
>
> >> Ok, so it seems to me that using two leading underscores is really the
> >> best option, since it's safe against collisions with Fortran and C
> >> user code, and also safe to use with -fdollar-ok.
> >>
> >> The attached patch adds double underscores for the vtabs, vtypes,
> >> class containers and temporaries.
> >
> > OK. Thanks for the patch!
>
> Committed as r166480.
>
> Thanks for all the helpful comments, everyone!

Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (revision 166419)
+++ gcc/fortran/module.c (working copy)
@@ -4372,8 +4372,8 @@ read_module (void)
     p = name;

   /* Exception: Always import vtabs & vtypes.  */
-  if (p == NULL && (strncmp (name, "vtab$", 5) == 0
-    || strncmp (name, "vtype$", 6) == 0))
+  if (p == NULL && (strncmp (name, "__vtab_", 5) == 0
+    || strncmp (name, "__vtype_", 6) == 0))
     p = name;

   /* Skip symtree nodes not in an ONLY clause, unless there

---8<---

Sorry for the late follow-up but current trunk still has the code
quoted above where we forgot to add 2 to the length parameter of both
strncmp calls.

I think it would be nice to teach the C and C++ frontends to warn
about this even though it might trigger in quite some code in the
wild.

Looking at gcc/fortran alone there are
gcc/fortran/interface.c:  if (strncmp (mode, "unformatted", 9) == 0) // 11 !
gcc/fortran/module.c:         && (strncmp (name, "__vtab_", 5) == 0 // 7 !
gcc/fortran/module.c:             || strncmp (name, "__vtype_", 6) == 0)) // 8!
gcc/fortran/module.c:             || (strncmp (name, "__vtab_", 5) != 0 // 7!
gcc/fortran/module.c:                 && strncmp (name, "__vtype_", 6)
!= 0)) // 8!

so warning by default with -Wall or at least per default in -Wextra
would make sense IMO.

cheers,

Reply via email to