Bug 18393 – REG(v2.078.1=>master) function re-declarations causes conflict, but should not

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-07T20:55:42Z
Last change time
2019-12-18T09:05:09Z
Assigned to
No Owner
Creator
Timothee Cour

Comments

Comment #0 by timothee.cour2 — 2018-02-07T20:55:42Z
``` void fun(); void fun(); ``` dmd -o- main.d DMD64 D Compiler v2.078.1 => ok DMD64 D Compiler v2.078.2-beta.1-653-g7e8bea0e8-dirty => Error: function test_all.fun() conflicts with previous declaration at main.d(20)
Comment #1 by timothee.cour2 — 2018-02-07T21:00:34Z
NOTE: it's in git master(git rev-parse HEAD 7e8bea0e83314f39b8c8b2bddbfbff2b0bdee74d) not in 2.078.2
Comment #2 by timothee.cour2 — 2018-02-07T21:32:38Z
on a vaguely related note: ``` void fun_bad3(T)(T a); void fun_bad3(T)(T a){} void test(){ fun_bad3(1); } ``` Error: test_all.fun_bad3 called with argument types (int) matches both: main.d(11): test_all.fun_bad3!int.fun_bad3(int a) and: main.d(12): test_all.fun_bad3!int.fun_bad3(int a) is that intended that only functions can be pre-declared, but not function templates?
Comment #3 by greensunny12 — 2018-02-07T23:20:07Z
It's not a bug, it's a feature - https://github.com/dlang/dmd/pull/7577 A lot better than the segfaults or silent errors you got before. DMD never supported this. I just didn't complain loudly to you before. > on a vaguely related note: That's a different issue. Please open a new issue ;-)
Comment #4 by timothee.cour2 — 2018-02-07T23:58:17Z
I'm confused: https://github.com/dlang/dmd/pull/7577/files says: Issue 14147 - Compiler crash on identical functions in a single module the bugs this fixes are cases of multiply defined functions, not multiply declared functions: in your eg in https://github.com/dlang/dmd/pull/7577/files: the bug i'm reporting below is multiply declared functions: ``` void fun(); void fun(); ``` why would this be OK: ``` void f1(); void f1() {} ``` but not this: ``` void f1(); void f1(); void f1() {} ``` ?
Comment #5 by timothee.cour2 — 2018-02-08T00:26:01Z
probably related to this PR: https://github.com/dlang/dmd/pull/7577/files#diff-3084a264389e086215b36670ae9f4a3dR392 snippet: /* Allow the hack that is actually used in druntime, + * to ignore function attributes for extern (C) functions. + * TODO: Must be reconsidered in the future. + * BUG: https://issues.dlang.org/show_bug.cgi?id=18206 + * + * extern(C): + * alias sigfn_t = void function(int); + * alias sigfn_t2 = void function(int) nothrow @nogc; + * sigfn_t bsd_signal(int sig, sigfn_t func); + * sigfn_t2 bsd_signal(int sig, sigfn_t2 func) nothrow @nogc; // no error + */ why would extern(C) be allowed to redeclare but not extern(C++)? from looking at druntime it shows: ``` extern(C): sigfn_t bsd_signal(int sig, sigfn_t func); sigfn_t2 bsd_signal(int sig, sigfn_t2 func); ``` indeed, `bsd_signal` is being redeclared... not sure i understand the details of why that’s needed but I don’t understand why extern(C++) would differ from extern(C)
Comment #6 by greensunny12 — 2018-02-08T00:35:31Z
Sorry about eagerly closing this. It seems that the following use shouldn't trigger the error. Multiple declaration of the same type if they both have no body.
Comment #7 by razvan.nitu1305 — 2018-12-18T15:04:14Z
I cannot reproduce the original bug example. Is this still valid? If not please close it.
Comment #8 by bugzilla — 2019-12-18T09:05:09Z
I can't reproduce the problem.