digitalmars.D.bugs - [Issue 16408] New: Converting char* to string with
- via Digitalmars-d-bugs (49/49) Aug 21 2016 https://issues.dlang.org/show_bug.cgi?id=16408
https://issues.dlang.org/show_bug.cgi?id=16408 Issue ID: 16408 Summary: Converting char* to string with std.conv.to!string is wrong in release mode Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: matthew.brennan.jones gmail.com This program prints WASD in debug mode as expected, but prints DDDD in release mode. My guess is std.conv.to!string is failing with char* for some reason. DMD 2.071.1 on Linux and Windows 10. Works as expected: dub run --arch=x86_64 --build=debug Wrong output: dub run --arch=x86_64 --build=release // maid.d import std.stdio; import std.string; import std.conv; import derelict.sdl2.sdl; int main() { DerelictSDL2.load(SharedLibVersion(2, 0, 2)); string footer = "%s%s%s%s".format( to!string(SDL_GetKeyName(SDLK_w)), to!string(SDL_GetKeyName(SDLK_a)), to!string(SDL_GetKeyName(SDLK_s)), to!string(SDL_GetKeyName(SDLK_d)), ); stdout.writeln(footer); return 0; } // dub.json { "name": "main", "targetType": "executable", "dependencies": { "derelict-sdl2": "~>2.0", }, "sourceFiles": [ "main.d" ], } --
Aug 21 2016