www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1933] New: Delimited string constants can cause segfault

reply d-bugmail puremagic.com writes:

           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:


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:


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...

Mar 20 2008
next sibling parent d-bugmail puremagic.com writes:

Joseph.Gauterin googlemail.com changed:

           What    |Removed                     |Added
                 CC|                            |Joseph.Gauterin googlemail.c
                   |                            |om

------- Comment #1 from Joseph.Gauterin googlemail.com  2008-07-16 17:06 -------
This can be reproduced using a file containing only the following:

and it's still a problem in D 2.014

Jul 16 2008
prev sibling parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #2 from bugzilla digitalmars.com  2008-12-25 04:41 -------
Fixed dmd 2.022

Dec 25 2008