Actually it's a regression:
https://forum.dlang.org/post/fwwhyqpdvmdyudtgi...@forum.dlang.org
On Sunday, 4 May 2025 at 00:15:23 UTC, Jonathan M Davis wrote:
That sounds like an ldc bug then. With dmd, your program gives
[2, 2, 2, 2, 1, 1, 1, 1]
[2, 2, 2, 2, 1, 1, 1, 1]
core.exception.RangeError@q.d(13): Range violation
??:? onRangeError [0x29f6b6]
??:? _d_arrayboundsp [0
On Saturday, May 3, 2025 8:23:00 AM Mountain Daylight Time Andy Valencia via
Digitalmars-d-learn wrote:
> At least on 1.40.1 of the ldc2 distro for x86-64, uses the
> "illegal instruction" instruction.
That sounds like an ldc bug then. With dmd, your program gives
[2, 2, 2, 2, 1, 1, 1, 1]
[2, 2,
But yeah, core.internal.util.array is wrong design, it should be
boolean function, and the compiler should generate
assert(areTypedArraysConformable()); at the caller side.
You link with release version of druntime, try to link with debug
version.
On Saturday, 3 May 2025 at 11:18:00 UTC, Nick Treleaven wrote:
Second, in assigning from arrays of differing sizes, Phobos
causes an illegal instruction, rather than the sort of
exception I'd have expected. I'm curious why they stepped
away from D's exception architecture?
It throws a RangeErr
On Friday, 2 May 2025 at 22:19:53 UTC, Andy Valencia wrote:
In the following code, two questions. First, is there any
difference between "x[] = y" and "x[] = y[]"? It appears not.
`y` is already a slice `int[]`, so slicing it does not change the
type. Slicing without indices selects all elem
On Friday, 2 May 2025 at 22:19:53 UTC, Andy Valencia wrote:
In the following code, two questions. First, is there any
difference between "x[] = y" and "x[] = y[]"?
With basic slices no; I could construct something with overloads
tho
```d
import std.stdio : writeln;
auto foo(ref int[] a, re
On Saturday, 19 November 2016 at 21:05:49 UTC, John Colvin wrote:
On Saturday, 19 November 2016 at 19:36:50 UTC, Marduk wrote:
Thanks a lot! Now I get what it means that array declarations
are read from right to left.
The way I think about it is this:
int is a type. int[3] is an array of 3 in
On Saturday, 19 November 2016 at 19:36:50 UTC, Marduk wrote:
On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin
wrote:
On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote:
Additionally, I would like to assign 2D sub-arrays of a 3D
array, i.e. something like the following:
int[
On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin wrote:
On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote:
Additionally, I would like to assign 2D sub-arrays of a 3D
array, i.e. something like the following:
int[3][2][2] a;
a[0] = [[2,2], [2,2]];
You have the dimensions
On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote:
Additionally, I would like to assign 2D sub-arrays of a 3D
array, i.e. something like the following:
int[3][2][2] a;
a[0] = [[2,2], [2,2]];
You have the dimensions the wrong way around. a is a 2 element
array of 2 element arrays o
On Saturday, 11 July 2015 at 13:31:12 UTC, Peter wrote:
So after looking into it a little bit...
So now I'm trying to multiply the array by a double but it's
giving incompatible type errors. opBinary, opBinaryRight, and
opOpAssign are defined.
I have:
struct Vector3 {
public double[3] _
On Saturday, 11 July 2015 at 13:31:12 UTC, Peter wrote:
The postblit can only not take @nogc due to the array
duplication which is understandable.
I think the postblit might be redundant anyway since the struct
is built on a static array so there is no possibility of two
different Vect3s "point
On Wednesday, 8 July 2015 at 06:05:54 UTC, ketmar wrote:
do you see the gotcha? if you uncomment postblit or assigns,
this build function fails to compile, as that operations aren't
"pure nothrow @nogc @trusted", and they will be used for either
assign or postblitting.
So after looking into i
On Tue, 07 Jul 2015 11:09:52 +, Peter wrote:
Any ideas about what's happening?
yes. there is code in "arrayop.c" that tells:
// Built-in array ops should be @trusted, pure, nothrow and
nogc
StorageClass stc = STCtrusted | STCpure | STCnothrow |
STCnogc;
under the hoods compile
On Monday, 6 July 2015 at 15:48:28 UTC, anonymous wrote:
Ok, I disabled everything in the struct except what I posted and
it ran.
I then uncommented stuff to isolate the cause. I've added in the
bits that cause the error below (plus some constructors just for
reference).
struct Vector3 {
On Monday, 6 July 2015 at 12:15:22 UTC, Peter wrote:
dmd 2.066.1, windows 7 64bit
Tested it on Windows 7, using dmd 2.066.1: works for me.
The exact code I tested (just commented those "..." out):
struct Vector3 {
public double[3] _p;
//...
Vector3 opBinary(string op)(in Vecto
On Monday, 6 July 2015 at 10:29:35 UTC, anonymous wrote:
Works for me with various versions of dmd on linux. What
compiler are you using, what version of it, what operating
system, etc?
dmd 2.066.1, windows 7 64bit
On Monday, 6 July 2015 at 03:02:59 UTC, Nicholas Wilson wrote:
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
[...]
unittest{
auto a = Vector3([2.0, 2.0, 0.0]);
auto b = Vector3([1.0, 2.0, 1.0]);
Vector3[] c = [a];
Vector3[] d = [b];
Vector3 e = a + b; // works
Vec
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
Hi,
I have a struct with arithmetic operations defined using
opBinary but array operations with arrays of it don't work.
struct Vector3 {
public double[3] _p;
...
Vector3 opBinary(string op)(in Vector3 rhs) const
if (op == "+
On Monday, 6 July 2015 at 03:02:59 UTC, Nicholas Wilson wrote:
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
Hi,
I have a struct with arithmetic operations defined using
opBinary but array operations with arrays of it don't work.
struct Vector3 {
public double[3] _p;
...
Ve
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote:
Hi,
I have a struct with arithmetic operations defined using
opBinary but array operations with arrays of it don't work.
struct Vector3 {
public double[3] _p;
...
Vector3 opBinary(string op)(in Vector3 rhs) const
if (op == "+
On Thursday, 2 July 2015 at 19:27:57 UTC, J Miller wrote:
I knew that automatic allocation doesn't happen, but I'm
confused by the fact if you explicitly declare "c" with "int[]
c;" and then assign "c[] = a[] * b[]", versus using "auto c =
a[] * b[]", you get two different errors (array length
On Thursday, 2 July 2015 at 12:59:03 UTC, Steven Schveighoffer
wrote:
On 7/2/15 8:21 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?=
" wrote:
On Thursday, 2 July 2015 at 10:48:56 UTC, Steven Schveighoffer
wrote:
On 7/1/15 8:36 PM, J Miller wrote:
Oh, and to make things really confusing, "auto e = a[] -
b[
On 7/2/15 8:21 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= " wrote:
On Thursday, 2 July 2015 at 10:48:56 UTC, Steven Schveighoffer wrote:
On 7/1/15 8:36 PM, J Miller wrote:
Oh, and to make things really confusing, "auto e = a[] - b[]" and "int[]
e = a[] - b[]" both cause "Error: array operation a[] - b
https://issues.dlang.org/show_bug.cgi?id=14759
On Thursday, 2 July 2015 at 10:48:56 UTC, Steven Schveighoffer
wrote:
On 7/1/15 8:36 PM, J Miller wrote:
Oh, and to make things really confusing, "auto e = a[] - b[]"
and "int[]
e = a[] - b[]" both cause "Error: array operation a[] - b[]
without
destination memory not allowed".
Using dmd 2.0
On 7/1/15 8:36 PM, J Miller wrote:
Oh, and to make things really confusing, "auto e = a[] - b[]" and "int[]
e = a[] - b[]" both cause "Error: array operation a[] - b[] without
destination memory not allowed".
Using dmd 2.067.0.
This is not a bug. You need to allocate memory before you can wri
On Wednesday, 1 July 2015 at 21:15:13 UTC, Marc Schütz wrote:
On Wednesday, 1 July 2015 at 19:09:36 UTC, Alex Parrill wrote:
I don't think this is a bug.
Since you don't initialize `c` to anything, it defaults to an
empty slice. Array [] operations apply to each element of a
slice, but `c` do
On Wednesday, 1 July 2015 at 19:09:36 UTC, Alex Parrill wrote:
I don't think this is a bug.
Since you don't initialize `c` to anything, it defaults to an
empty slice. Array [] operations apply to each element of a
slice, but `c` doesn't have any elements, so it does nothing.
I _do_ think it'
On Tuesday, 30 June 2015 at 22:37:34 UTC, ixid wrote:
int[] a = [1,1,1,1];
int[] b = [1,1,1,1];
int[] c;
c[] = a[] - b[];
c.writeln;
This outputs []. This feels wrong, it feels like something that
should have exploded or set the length to 4. If the leng
On Tuesday, 30 June 2015 at 22:37:34 UTC, ixid wrote:
int[] a = [1,1,1,1];
int[] b = [1,1,1,1];
int[] c;
c[] = a[] - b[];
c.writeln;
This outputs []. This feels wrong, it feels like something that
should have exploded or set the length to 4. If the leng
Márcio Martins:
float[10] a;
a[] = uniform(0.0f, 1.0f);
This is going to set all values to the result of a single call
to uniform();
Is there a way to express my intent that I want one result per
array element?
Currently D array operations can't be used for that kind of
usage. So you hav
On 07.08.2010 14:10, simendsjo wrote:
I'm new to D2, so please.. :)
(...)
Thanks for all answers. Seems array operations is a bit buggy, so I'll
rather look more into them at a later date.
Don:
> That is bug 4578, which has been fixed, and will be in the next compiler
> release.
Good, there is no need to file it then.
simendsjo post shows two more cases, this is the first:
> {
> double[3] a = [1,1,1];
> auto b = a[] + 3; // What happens here?
>
Sorry for the late answer, I am quite busy now. Mafi has already answered, I
will probably repeat some things already said.
simendsjo:
Array ops currently have many bugs, they are fragile asm glass things, so when
you use them you have to be kind, if you misuse them a bit things crash and
burn
Mafi wrote:
Hey, here Mafi again,
I thought about your snippets and here's what I have.
Am 07.08.2010 14:10, schrieb simendsjo:
{ // Like the previous example, but with dynamic arrays..
double[] a = [1,1,1];
auto b = a;
assert(a is b);
b = a[] + 3;
assert(a == [1,1,1]);
//writeln(b); // acces
Hey, here Mafi again,
I thought about your snippets and here's what I have.
Am 07.08.2010 14:10, schrieb simendsjo:
{
double[3] a = [1,1,1];
double[3] b;
b[] = a[] + 3;
assert(a == [1,1,1]);
assert(b == [4,4,4]);
}
{
double[3] a = [1,1,1];
auto b = a;
b[] = a[] + 3;
assert(a == [1,1,1]);
assert
Am 07.08.2010 14:10, schrieb simendsjo:
I'm new to D2, so please.. :)
The spec on Array Operations,
http://www.digitalmars.com/d/2./arrays.html says:
"""A vector operation is indicated by the slice operator appearing as
the lvalue of an =, +=, -=, *=, /=, %=, ^=, &= or |= operator."""
The follo
40 matches
Mail list logo