On Sunday, 28 November 2021 at 13:58:49 UTC, Sebastien Alaiwan wrote:
Hi,

It seems that the output target name gets corrupted (see the extra chars at the end of 'MyTargetName'):

    *$ cat test.d*
    // empty file

*$ gdc -Isrc -MM "test.d" -MT "MyTargetName" -MF "test.deps"*

    *$ cat test.deps*
    MyTargetName�: test.d

    *$ gdc --version*
    gdc (Debian 11.2.0-10) 11.2.0
    Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    *$*


Here's the fix I'm suggesting:

    diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
    index be6330fbd..4749bfb98 100644
    --- a/gcc/d/d-lang.cc
    +++ b/gcc/d/d-lang.cc
@@ -110,6 +110,7 @@ deps_add_target (const char *target, bool quoted)
        if (!quoted)
          {
            obstack_grow0 (&buffer, target, strlen (target));
    +      obstack_1grow (&buffer, '\0');
       d_option.deps_target.safe_push ((const char *) obstack_finish (&buffer));
            return;
          }


Hi Sebastien,

That doesn't look right, obstack_grow0() already adds a null terminator. Did you test building current mainline to see if the issue still occurs?

In all likelihood I just need to backport this patch which got applied back in July.

https://gcc.gnu.org/pipermail/gcc-patches/2021-July/576395.html

Which coincidentally, I was just asked to backport it to gcc-11 just the other day too.

https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585450.html

Iain.




Reply via email to