Bug 12788 – -di doesn't warn about implicit conversion from char[] to char*

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2014-05-23T11:10:00Z
Last change time
2014-08-11T10:20:53Z
Keywords
industry
Assigned to
nobody
Creator
leandro.lucarella

Comments

Comment #0 by leandro.lucarella — 2014-05-23T11:10:10Z
Test case: --- void f(char* s) {} void g(char[] s) { f(s); } --- $ dmd -c test.d test.d(4): Error: function test.f (char* s) does not match parameter types (char[]) test.d(4): Error: cannot implicitly convert expression (s) of type char[] to char* $dmd -c -di test.d // compiles without warnings
Comment #1 by leandro.lucarella — 2014-05-23T11:14:53Z
BTW, this seems somehow harmless, but when using -di by default, it's quite dangerous, as you can easily end up passing non-null terminated strings to C without noticing!
Comment #2 by github-bugzilla — 2014-08-11T07:44:14Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c5703152c58242b46e7e2c8ef6e0a906b9e4b6a0 fix Issue 12788 - -di doesn't warn about implicit conversion from char[] to char*
Comment #3 by leandro.lucarella — 2014-08-11T10:20:53Z
Thanks!