Jump to page: 1 2
Thread overview
[Issue 16381] Wrapping a float4 array leads to segfault.
Aug 12, 2016
Bartek Siudeja
Aug 12, 2016
Bartek Siudeja
Aug 12, 2016
b2.temp@gmx.com
Aug 12, 2016
b2.temp@gmx.com
Aug 12, 2016
Bartek Siudeja
Aug 12, 2016
b2.temp@gmx.com
Aug 12, 2016
Bartek Siudeja
Aug 12, 2016
ag0aep6g@gmail.com
Aug 12, 2016
b2.temp@gmx.com
Aug 12, 2016
b2.temp@gmx.com
Nov 20, 2016
Walter Bright
Nov 20, 2016
Walter Bright
Nov 20, 2016
Walter Bright
Mar 21, 2020
Basile-z
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #1 from Bartek Siudeja <siudej@gmail.com> ---
dmd: 2.068, 2.069 and 2.071

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

Bartek Siudeja <siudej@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |major

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #2 from b2.temp@gmx.com ---
If the opIndex header is changed to

  ref float4 opIndex(size_t idx)
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #3 from Bartek Siudeja <siudej@gmail.com> ---
True, but:

My wrapper is a superclass of an abstract storage class, and not all implementations can return a reference to float4. Another superclass looks more or less like std.container.Array!bool, so the common interface/base class can't use ref.

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #4 from b2.temp@gmx.com ---
(In reply to Bartek Siudeja from comment #3)
> True, but:
> 
> My wrapper is a superclass of an abstract storage class, and not all implementations can return a reference to float4. Another superclass looks more or less like std.container.Array!bool, so the common interface/base class can't use ref.

I don't suggest you do to do like this. I've added the extra info for the person who'll fix it. The information added by "it works with ref" is that the copy is not valid since any access to ".ptr" leads to an AV.

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #5 from Bartek Siudeja <siudej@gmail.com> ---
If you do know a workaround I could use, I would be really grateful.

Was checking some other options. Even changing opIndex into something like:

float4 test(size_t idx)
{
    float4 temp = arr[idx];
    return temp;
}

does not help. So this seems about the return value of a function.

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |ag0aep6g@gmail.com

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #6 from b2.temp@gmx.com ---
(In reply to Bartek Siudeja from comment #5)
> does not help. So this seems about the return value of a function.

Yes that's also what I said: return value == copy because float[4] doesn't fit in a CPU register. when ref is used it's actually the address of the first float that's returned.

Anyway it's clearly a front-end error, because even LDC returns a run-time error:

> Invalid bitcast
>   %63 = bitcast [4 x float] %62 to float
> LLVM ERROR: Broken function found, compilation aborted!

--
August 12, 2016
https://issues.dlang.org/show_bug.cgi?id=16381

--- Comment #7 from b2.temp@gmx.com ---
(In reply to b2.temp from comment #6)
> (In reply to Bartek Siudeja from comment #5)
> > does not help. So this seems about the return value of a function.
> 
> Yes that's also what I said: return value == copy because float[4] doesn't fit in a CPU register. when ref is used it's actually the address of the first float that's returned.
> 
> Anyway it's clearly a front-end error, because even LDC returns a run-time error:
> 
> > Invalid bitcast
> >   %63 = bitcast [4 x float] %62 to float
> > LLVM ERROR: Broken function found, compilation aborted!

"compile-time error" is what I really meant...

--
« First   ‹ Prev
1 2