Bug 903 – Example with printf and string literals crashes
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-01-29T10:05:00Z
Last change time
2014-02-15T13:12:43Z
Keywords
spec
Assigned to
bugzilla
Creator
torhu
Comments
Comment #0 by torhu — 2007-01-29T10:05:07Z
From http://www.digitalmars.com/d/arrays.html :
"String literals already have a 0 appended to them, so can be used directly:
printf("the string is '%s'\n", "string literal");"
That gives an access violation, because "string literal" is a dynamic array. Probably changed with dmd 0.177. Somehow I wish D would make an exception for string literals and C functions. It's too easy to get this wrong when it works for fixed arguments, just not for variable ones.