Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 48dea88

Browse files
pbackusdlang-bot
authored andcommitted
Fix issue 22763 - importing std.utf fails in BetterC
BetterC-compatible code should be allowed to import the symbols in this module, as long as it does not attempt to use them at runtime when compiled in BetterC mode.
1 parent 1cb7499 commit 48dea88

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/core/exception.d

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,6 @@ void __switch_errorT()(string file = __FILE__, size_t line = __LINE__) @trusted
1919
assert(0, "No appropriate switch clause found");
2020
}
2121

22-
version (D_BetterC)
23-
{
24-
// When compiling with -betterC we use template functions so if they are
25-
// used the bodies are copied into the user's program so there is no need
26-
// for the D runtime during linking.
27-
28-
// In the future we might want to convert all functions in this module to
29-
// templates even for ordinary builds instead of providing them as an
30-
// extern(C) library.
31-
32-
void onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
33-
{
34-
assert(0, "Memory allocation failed");
35-
}
36-
alias onOutOfMemoryErrorNoGC = onOutOfMemoryError;
37-
38-
void onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
39-
{
40-
assert(0, "Invalid memory operation");
41-
}
42-
}
43-
else:
44-
4522
/**
4623
* Thrown on a range error.
4724
*/
@@ -692,26 +669,49 @@ extern (C) void onFinalizeError( TypeInfo info, Throwable e, string file = __FIL
692669
throw staticError!FinalizeError(info, e, file, line);
693670
}
694671

695-
/**
696-
* A callback for out of memory errors in D. An $(LREF OutOfMemoryError) will be
697-
* thrown.
698-
*
699-
* Throws:
700-
* $(LREF OutOfMemoryError).
701-
*/
702-
extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
672+
version (D_BetterC)
703673
{
704-
// NOTE: Since an out of memory condition exists, no allocation must occur
705-
// while generating this object.
706-
throw staticError!OutOfMemoryError();
707-
}
674+
// When compiling with -betterC we use template functions so if they are
675+
// used the bodies are copied into the user's program so there is no need
676+
// for the D runtime during linking.
708677

709-
extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc
710-
{
711-
// suppress stacktrace until they are @nogc
712-
throw staticError!OutOfMemoryError(false);
678+
// In the future we might want to convert all functions in this module to
679+
// templates even for ordinary builds instead of providing them as an
680+
// extern(C) library.
681+
682+
void onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
683+
{
684+
assert(0, "Memory allocation failed");
685+
}
686+
alias onOutOfMemoryErrorNoGC = onOutOfMemoryError;
687+
688+
void onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted
689+
{
690+
assert(0, "Invalid memory operation");
691+
}
713692
}
693+
else
694+
{
695+
/**
696+
* A callback for out of memory errors in D. An $(LREF OutOfMemoryError) will be
697+
* thrown.
698+
*
699+
* Throws:
700+
* $(LREF OutOfMemoryError).
701+
*/
702+
extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
703+
{
704+
// NOTE: Since an out of memory condition exists, no allocation must occur
705+
// while generating this object.
706+
throw staticError!OutOfMemoryError();
707+
}
714708

709+
extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc
710+
{
711+
// suppress stacktrace until they are @nogc
712+
throw staticError!OutOfMemoryError(false);
713+
}
714+
}
715715

716716
/**
717717
* A callback for invalid memory operations in D. An

0 commit comments

Comments
 (0)