Skip to content

Exception.toString not useable in @safe #20573

@braddr

Description

@braddr

This code (extracted from a larger project):

module safety;

import core.sys.posix.stdio : printf;
import std.exception;

void main() @safe
{
    try
    {
        throw new Exception("irrelevant");
    }
    catch (Exception e)
    {
        string s = e.toString();
    }
}

Results in:

safety.d(14): Error: `@safe` function `D main` cannot call `@system` function `object.Throwable.toString`
/home/braddr/sandbox/dmd.2.109.1/linux/bin64/../../src/druntime/import/object.d(2652):        `object.Throwable.toString` is declared here

Metadata

Metadata

Assignees

No one assigned

    Labels

    DruntimeSpecific to druntime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions