[Issue 17541] Function attribute deduction depends on compile invocation

2023-08-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #15 from Dlang Bot  ---
@ljmf00 created dlang/dmd pull request #15534 "Fix Issue 17541 -
@safe/pure/nothrow attribute deduction depends on c…" fixing this issue:

- Fix Issue 17541 - @safe/pure/nothrow attribute deduction depends on compile
invocation

  A reboot of #10959 follow-up plus implementation for `nothrow`.

  Signed-off-by: Luís Ferreira 

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

--


[Issue 17541] Function attribute deduction depends on compile invocation

2023-02-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Paul Backus  changed:

   What|Removed |Added

 CC||212fahrenh...@posteo.us

--- Comment #14 from Paul Backus  ---
*** Issue 23723 has been marked as a duplicate of this issue. ***

--


[Issue 17541] Function attribute deduction depends on compile invocation

2023-02-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Paul Backus  changed:

   What|Removed |Added

 CC||snarwin+bugzi...@gmail.com

--- Comment #13 from Paul Backus  ---
Another example, from Discord:

--- test.d
module test;

void main(){
import test2;
MyStruct.RcPtr gl_indcies = MyStruct.RcPtr(MyStruct());
}
--- test2.d
module test2;

struct MyStruct{
alias Ptr = Unique!MyStruct;
alias RcPtr = SafeRefCounted!MyStruct;
~this(){}
}

struct SafeRefCounted(T){
struct RefCountedStore{
struct Impl{
T _payload;
}
Impl* _store;
}
RefCountedStore* _refCounted;

this(T)(T arg){}
~this(){
destroy(_refCounted._store._payload);
}
}

struct Unique(T){
alias RefT = T*;
void opAssign(U)(Unique!U u) if (is(u.RefT:RefT)){}

~this(){
destroy(*_p);
}
RefT _p;
}
---

When compiled together, there is no error:

---
$ dmd -c test.d test2.d && dmd test.o test2.o
$ echo $?
0
---

When compiled separately, linking fails:

---
$ dmd -c test.d && dmd -c test2.d && dmd test.o test2.o
/usr/bin/ld: test.o: in function `_Dmain':
test.d:(.text._Dmain[_Dmain]+0x2f): undefined reference to
`_D5test2__T14SafeRefCountedTSQBb8MyStructZQBf6__dtorMFZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
---

Examining the object files shows that this is due to mismatched attributes:

---
$ nm test.o | ddemangle | grep 'SafeRefCounted.*__dtor'
 U void
test2.SafeRefCounted!(test2.MyStruct).SafeRefCounted.__dtor()
$ nm test2.o | ddemangle | grep 'SafeRefCounted.*__dtor'
 W pure nothrow @nogc @safe void
test2.SafeRefCounted!(test2.MyStruct).SafeRefCounted.__dtor()
---

Reproduced with DMD 2.102.0 on 64-bit Linux.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P1  |P3

--


[Issue 17541] Function attribute deduction depends on compile invocation

2020-03-24 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

--- Comment #12 from johanenge...@weka.io ---
(In reply to Walter Bright from comment #11)
> I cannot reproduce the problem. The previous fix I pushed was wrong.
> 
> The pragma(msg, insertabcdefg.mangleof) gives the wrong name mangling, as it
> happens before the inference is complete. The compiler should give an error
> for that.

The pragma(msg, insertabcdefg.mangleof) is not the only bug here. The larger
pain point is that deduction depends on compiler invocation and hence breaks
separate compilation (either for linking symbol resolution, or for code
depending on a certain attribute deduction result).
Tested with dlang 2.090.1 just now, replacing `@nogc` with `pure`, and
following reproduction commands shows the problem:

❯ ~/dlang/dmd20901/osx/bin/dmd one.d -c -of=tmp1.o
   
   
  ❯ nm tmp1.o| grep "insertabc"
02ac S __D5three__T2TTTiZQg13insertabcdefgMFNaiZv
0078 S __D5three__T2TTTiZQg13insertabcdefgMFNaiZv.eh

❯ dmd one.d two.d three.d -c -of=tmp2.o

❯ nm tmp2.o | grep "insertabc"
03b4 S __D5three__T2TTTiZQg13insertabcdefgMFiZv
00c0 S __D5three__T2TTTiZQg13insertabcdefgMFiZv.eh

The symbol names in the binary are different.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2020-03-24 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Walter Bright  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=20696

--


[Issue 17541] Function attribute deduction depends on compile invocation

2020-03-24 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

--- Comment #11 from Walter Bright  ---
I cannot reproduce the problem. The previous fix I pushed was wrong.

The pragma(msg, insertabcdefg.mangleof) gives the wrong name mangling, as it
happens before the inference is complete. The compiler should give an error for
that.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2020-03-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

--- Comment #10 from Dlang Bot  ---
@WalterBright created dlang/dmd pull request #10959 "add pure and @safe to
correct for issue 17541" mentioning this issue:

- add pure and @safe to correct for issue 17541

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

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-12-18 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

johanenge...@weka.io changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #9 from johanenge...@weka.io ---
reopening, because it is not fixed for safe/trusted, nor for impure/pure,
throw/nothrow.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-12-18 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-12-18 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

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

https://github.com/dlang/dmd/commit/df847ccb60a37f4dbc349e8cee4a2ee6081e0c3c
fix Issue 17541 - Function attribute deduction depends on compile invocation

https://github.com/dlang/dmd/commit/aabeeb0a550a0d4ba066209290c799c5cf812e87
Merge pull request #6995 from WalterBright/fix17541

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-10-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

johanenge...@weka.io changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #7 from johanenge...@weka.io ---
reopening, because it is not fixed for safe/trusted, nor for impure/pure,
throw/nothrow.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-10-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-10-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

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

https://github.com/dlang/dmd/commit/df847ccb60a37f4dbc349e8cee4a2ee6081e0c3c
fix Issue 17541 - Function attribute deduction depends on compile invocation

https://github.com/dlang/dmd/commit/aabeeb0a550a0d4ba066209290c799c5cf812e87
Merge pull request #6995 from WalterBright/fix17541

fix Issue 17541 - Function attribute deduction depends on compile inv…

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-07-14 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #5 from Walter Bright  ---
https://github.com/dlang/dmd/pull/6995

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-07-14 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

Steven Schveighoffer  changed:

   What|Removed |Added

   Keywords||wrong-code

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-07-14 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

--- Comment #4 from johanenge...@weka.io ---
This problem is bigger than just templates.
I am seeing more and more deduction errors, resulting in linker errors.

--


[Issue 17541] Function attribute deduction depends on compile invocation

2017-07-14 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17541

johanenge...@weka.io changed:

   What|Removed |Added

Summary|Template attribute  |Function attribute
   |deduction depends on|deduction depends on
   |compile invocation  |compile invocation

--