| |
 | Posted by d-bugmail | Permalink Reply |
|
d-bugmail 
| http://d.puremagic.com/issues/show_bug.cgi?id=1933
Summary: Delimited string constants can cause segfault
Product: D
Version: 2.007
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla@digitalmars.com
ReportedBy: unknown@simplemachines.org
The documentation (which is somewhat unclear) seems to indicate that the
following is incorrect:
q"
EOS
...
EOS"
If you try this, it will cause a segfault. The reason is that once we leave
the switch in delimitedStringConstant(), c is '\n' (because of the break.)
This ends up meaning delimleft and delimright are '\n', as best I can reason
(haven't spent time debugging code yet.)
Simple solution to me seems like either adding an if inside |if (delimleft == 0)| to check that c is not whitespace, or adding a branch before it to ignore whitespace (depending on which is the correct interpretation of the spec.)
Also would be nice if the spec were clearer (e.g. "the delimiter, whether a character or identifier, must immediately follow the " without any whitespace. If the delimiter is an identifier, it must similarly immediately proceed the terminating ".)
I realize my D version is a bit outdated, but this diff shows the problem can't have been fixed yet for 2.012:
http://www.dsource.org/projects/dsss/changeset?new=branches%2Fdmdfe-2.0%2Flexer.c%40883&old=branches%2Fdmdfe-2.0%2Flexer.c%40838
Not sure if you care for my patches, but if I have time I'll try to look into this more and attach a patch (since I'm fairly confident the whitespace isn't supposed to be allowed.)
Thanks. I noticed this because I was writing my own lexer, not because I was actually using the heredocs... I have to say token and delimited strings complicated my lexer more than I expected...
--
|