[Issue 9418] Segmentation fault using only datetime and stdio.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 5 09:51:40 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9418


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-02-05 09:51:39 PST ---
(In reply to comment #1)
> How strange, what is the tilde operating on in this code? For example:

Indeed this is strange.

> import std.datetime;
> import std.stdio;
> 
> void main()
> {
>     auto x1 = ~Clock; // NG
>     auto x2 = ~Clock.currTime(); // NG
>     auto x3 = ~Clock.currTime().toISOString(); // NG
>     auto x4 = Clock.currTime().toISOString()[0 .. 8];
>     auto x5 = ~x4;  // NG
>     auto x5 = ~Clock.currTime().toISOString()[0 .. 8];  // works?!
> }

Actually it operates on dynamic array honestly corrupting (complementing) both
length and ptr properties.

import core.stdc.stdio : printf;

void main()
{
    string foo = "foo";
    printf(".length = %d, .ptr=%p\n", foo.length, foo.ptr);
    foo = ~foo[] ;
    printf(".length = %d, .ptr=%p\n", foo.length, foo.ptr);
}

My guess is that slice expression escapes internal dmd checks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list