You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
The testcase dies with an access violation with DMD 2.074 on Windows:
object.Error@(0): Access Violation
----------------
0x0041C60D in memcmp
0x00402263 in pure nothrow @nogc @safe int object.__cmp!(void, const(void)).__cmp(void[], const(void)[]) at C:\LDC\dmd2\windows\bin\..\..\src\druntime\import\object.d(3407)
0x004021F7 in _Dmain at C:\LDC\ninja-ldc\..\current.d(27)
I think that (T[] a, U[] b) => a == b, (T[] a, U[] b) => a < b and friends should be disallowed if either is(Unqual!T == void) or is(Unqual!U == void) and allow only a is b.
I don't have a strong opinion on a < b for void[] arrays, but I'm very much against disabling the (in)equality check. I'm under the impression that void[] is used quite often, to describe an untyped range of memory, so having to cast all of these manually when checking for (in)equality seems damn ugly and inconvenient to me. (edit: yep, that should be fine via is).
Much more importantly, the front-end should make sure bugs like these can't occur (and the DMD backend hardened in this regard). The nested function indexes the void[] array, returns a void by ref (!), the test takes the (apparently invalid) address of the returned void reference and forwards it to memcmp...
Indexing a void[] array could be useful to obtain addresses (&slice[2], but that can be done more cleanly via slice.ptr + 2), but a function returning ref void and taking the address of a void value is... definitely strange. :]
If returning a ubyte when indexing a void[] array is deemed too strange, I'd be in favor of just prohibiting it (slicing obviously still allowed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The testcase dies with an access violation with DMD 2.074 on Windows: