Thread overview
[Issue 18955] extern(C++) default struct mangling is overridden when interacting with a `cppmangle = class` template
[Issue 18955] extern(C++) default struct mangling is overridden when interacting with a `cppmangle = class` tamplate
Jun 08, 2018
Manu
Jul 12, 2018
Mike Franklin
Jul 12, 2018
Manu
Jul 13, 2018
Manu
Aug 28, 2018
Mike Franklin
June 08, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |C++, industry

--- Comment #1 from Manu <turkeyman@gmail.com> ---
This symptom is a result of the same logic that causes the related ICE at
typesem.d:~1310
I don't understand the logic, perhaps Walter can take a look who understands
the intent of that code?

--
July 12, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #2 from Mike Franklin <slavo5150@yahoo.com> ---
`alias string = basic_string!(char, char_traits!char);` has two template
arguments, but `extern (C++, class) struct basic_string(T, Traits, Alloc)` had
3.

This results in:
Error: template instance `basic_string!(char, char_traits!char)` does not match
template declaration

I'm not sure what I should be doing to reproduce the problem.

--
July 12, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #3 from Manu <turkeyman@gmail.com> ---
I'm sorry. I think I must have cut&paste fail-ed. Remove the `Alloc` arg:
-------------------------------
extern (C++, std)
{
        struct char_traits(Char)
        {
        }
        extern (C++, class) struct basic_string(T, Traits)
        {
        }
        alias test_string = basic_string!(char, char_traits!char);
}
extern (C++) void test(ref const(std.test_string) str) {}
pragma(msg, test.mangleof);
-------------------------------

Compile that, it will emit:
  ?test@@YAXAEBV?$basic_string@DV?$char_traits@D@std@@@std@@@Z
But it should emit:
  ?test@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@@std@@@Z

Notice the 'V?$char_traits' (class) should be a 'U?$char_traits' (struct);
char_traits is a struct.

If you add:
    extern (C++, struct) struct char_traits(Char)

ie, tell it explicitly to mangle the struct as a struct, it mangles correctly. Of course, a struct should mangle as a struct naturally though.

--
July 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|extern(C++) default struct  |extern(C++) default struct
                   |mangling is overridden when |mangling is overridden when
                   |interacting with a          |interacting with a
                   |`cppmangle = class`         |`cppmangle = class`
                   |tamplate                    |template

--- Comment #4 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Saw the name in the D blog, had to fix it... Darn OCD.

--
July 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #5 from Manu <turkeyman@gmail.com> ---
Not sure what that post means..

--
July 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #6 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Sorry, I fixed a typo in the title of the bug report "tamplate".

--
August 28, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #7 from Mike Franklin <slavo5150@yahoo.com> ---
Attempted fix:  https://github.com/dlang/dmd/pull/8631

--
September 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/768198c87f562de08c3dfb8b1d32ace9287d1617 Fix Issue 18955 - extern(C++) default struct mangling is overridden when interacting with a cppmangle = class template

https://github.com/dlang/dmd/commit/51c1138fae497b11f05890413ec9e323d2948bee Merge pull request #8631 from JinShil/fix_18955

Fix Issue 18955 - extern(C++) default struct mangling is overridden when interacting with a cppmangle = class template

--
September 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
September 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18955

--- Comment #9 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a1a87203a1f01c79a96ffbc1a45cece2fed6501e add test for issue 18955

https://github.com/dlang/dmd/commit/00f4c42c92da7fd590a8edf8dc6c6562fe988fe4 Merge pull request #8708 from rainers/test_18955

add test for issue 18955
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>

--