Thread overview
[Issue 14979] [REG2.068] Wrong tempCString result on x64 with ternary operator
Aug 30, 2015
Kenji Hara
Aug 30, 2015
Kenji Hara
Aug 31, 2015
Kenji Hara
Aug 31, 2015
Kenji Hara
Sep 02, 2015
Kenji Hara
August 30, 2015
https://issues.dlang.org/show_bug.cgi?id=14979

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
Perhaps the root is issue 14696.

--
August 30, 2015
https://issues.dlang.org/show_bug.cgi?id=14979

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
OK, I confirmed this is actually a dup of issue 14696.

To reproduce the issue, we need to specify -unittest. By that, tempCString will make the buffer size smaller and the used heap memory will be destructed at the wrong timing.

auto tempCString(To = char, From)(From str)
    if (isSomeChar!To && (isInputRange!From || isSomeString!From) &&
        isSomeChar!(ElementEncodingType!From))
{
    ...
    static struct Res
    {
        ...

    private:
        To* _ptr;
        version (unittest)
        {
            enum buffLength = 16 / To.sizeof;
            // smaller size to trigger reallocations
        }
        else
        {
            enum buffLength = 256 / To.sizeof;
            // production size
        }

        To[256 / To.sizeof] _buff;  // the 'small string optimization'

--
August 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14979

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/5003

--
August 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14979

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |14696

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=14979
Issue 14979 depends on issue 14696, which changed state.

Issue 14696 Summary: destructor for temporary called before statement is complete with conditional operator https://issues.dlang.org/show_bug.cgi?id=14696

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

--
September 02, 2015
https://issues.dlang.org/show_bug.cgi?id=14979

Kenji Hara <k.hara.pg@gmail.com> changed:

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

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Kenji Hara from comment #3)
> https://github.com/D-Programming-Language/dmd/pull/5003

PR is merged in:

https://github.com/D-Programming-Language/dmd/commit/38d31b0364e555ce42a8f47ca656e59b1cf90aad

--
November 28, 2019
https://issues.dlang.org/show_bug.cgi?id=14979
Issue 14979 depends on issue 14696, which changed state.

Issue 14696 Summary: destructor for temporary called before statement is complete with conditional operator https://issues.dlang.org/show_bug.cgi?id=14696

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

--
November 29, 2019
https://issues.dlang.org/show_bug.cgi?id=14979
Issue 14979 depends on issue 14696, which changed state.

Issue 14696 Summary: destructor for temporary called before statement is complete with conditional operator https://issues.dlang.org/show_bug.cgi?id=14696

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

--