Jump to page: 1 2
Thread overview
[Issue 21807] Non-immutable data can be converted to immutable using function call in ctor
Apr 07, 2021
Temtaime
Apr 07, 2021
Paul Backus
Apr 07, 2021
anonymous4
Apr 07, 2021
Paul Backus
Apr 07, 2021
Dlang Bot
Apr 08, 2021
Dlang Bot
Apr 09, 2021
Dlang Bot
Apr 09, 2021
Dlang Bot
Oct 20, 2021
Dlang Bot
Aug 09, 2022
Walter Bright
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #1 from Temtaime <temtaime@gmail.com> ---
Or at least
 Deprecation: slice of static array temporary returned by X assigned to longer
lived variable Y

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com

--- Comment #2 from Paul Backus <snarwin+bugzilla@gmail.com> ---
If `bb` and the constructor are marked as @safe, DMD produces the following error:

---
Error: reference to stack allocated value returned by bb() assigned to
non-scope this.str
---

Separately from this, compiling with `-preview=dip1000` causes DMD to produce the following error:

---
Error: cannot implicitly convert expression bb() of type char[12] to string
---

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg
           Severity|critical                    |regression

--- Comment #3 from moonlightsentinel@disroot.org ---
Up to      2.062  : Failure with output: onlineapp.d(6): Error: cannot
implicitly convert expression (bb()) of type char[12LU] to string
Since      2.063  : Success and no output

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #4 from moonlightsentinel@disroot.org ---
Introduced by https://github.com/dlang/dmd/pull/1519

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #5 from anonymous4 <dfj1esp02@sneakemail.com> ---
char[] a(const int[] arr) pure @safe;
void b(const int[] arr) @safe
{
    char[] c=a(arr);
    string d=a(arr);
}

For this code dip1000 rejects the conversion to string too. How is it related to dip1000?

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #6 from Paul Backus <snarwin+bugzilla@gmail.com> ---
(In reply to anonymous4 from comment #5)
> char[] a(const int[] arr) pure @safe;
> void b(const int[] arr) @safe
> {
>     char[] c=a(arr);
>     string d=a(arr);
> }
> 
> For this code dip1000 rejects the conversion to string too. How is it related to dip1000?

It's not related to dip1000. Passing `-preview=dip1000` causes a different code path to be taken in the compiler, which ends up avoiding this bug by coincidence.

--
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12398 "Issue 21807 - Missing deprecation when slicing static array temporary..." was merged into stable:

- 5110b4e6dc9849001b273bd443a2b67ac490dd1b by MoonlightSentinel:
  Issue 21807 - Missing deprecation when slicing static array temporary...

  ...in class methods.

  The checks for such slices relied on `va` while actually just caring
  about the current type. This was broken by [1] which clears `va` for
  class members to detect escapes of delegates.

  This also applied to the checks for struct temporaries/literals.

  [1] https://github.com/dlang/dmd/pull/8008

https://github.com/dlang/dmd/pull/12398

--
April 08, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@MoonlightSentinel updated dlang/dmd pull request #12402 "Fix 21229 - Accept construction of union member as initialization" mentioning this issue:

- Issue 21807 - Missing deprecation when slicing static array temporary...

  ...in class methods.

  The checks for such slices relied on `va` while actually just caring
  about the current type. This was broken by [1] which clears `va` for
  class members to detect escapes of delegates.

  This also applied to the checks for struct temporaries/literals.

  [1] https://github.com/dlang/dmd/pull/8008

https://github.com/dlang/dmd/pull/12402

--
April 09, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
@MoonlightSentinel created dlang/dmd pull request #12408 "Merge stable into master" mentioning this issue:

- Issue 21807 - Missing deprecation when slicing static array temporary...

  ...in class methods.

  The checks for such slices relied on `va` while actually just caring
  about the current type. This was broken by [1] which clears `va` for
  class members to detect escapes of delegates.

  This also applied to the checks for struct temporaries/literals.

  [1] https://github.com/dlang/dmd/pull/8008

https://github.com/dlang/dmd/pull/12408

--
April 09, 2021
https://issues.dlang.org/show_bug.cgi?id=21807

--- Comment #10 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12408 "Merge stable into master" was merged into master:

- aea9ec8b1ce67f340a7a95564d3b2e8ae2de8d15 by MoonlightSentinel:
  Issue 21807 - Missing deprecation when slicing static array temporary...

  ...in class methods.

  The checks for such slices relied on `va` while actually just caring
  about the current type. This was broken by [1] which clears `va` for
  class members to detect escapes of delegates.

  This also applied to the checks for struct temporaries/literals.

  [1] https://github.com/dlang/dmd/pull/8008

https://github.com/dlang/dmd/pull/12408

--
« First   ‹ Prev
1 2