A little quiz. This is related to a recent post of mine in the main D
newsgroup, but please don't take a look at that post yet. This is the original
function:
double[][] matgen(int n) {
double[][] a;
double tmp = 1.0 / n / n;
a.length = n;
for (int i = 0; i < n; ++i) a[i].length
On 28-04-2011 13:02, bearophile wrote:
A little quiz. This is related to a recent post of mine in the main D
newsgroup, but please don't take a look at that post yet. This is the original
function:
double[][] matgen(int n) {
double[][] a;
double tmp = 1.0 / n / n;
a.length = n;
On Thu, 28 Apr 2011 08:02:40 -0400, bearophile
wrote:
A little quiz. This is related to a recent post of mine in the main D
newsgroup, but please don't take a look at that post yet. This is the
original function:
double[][] matgen(int n) {
double[][] a;
double tmp = 1.0 / n / n;
bearophile Wrote:
> auto a = new double[][](n, n);
And this really allocs tag array?
ps lol, didn't see the unsigned bug.
On Thu, 28 Apr 2011 08:02:40 -0400, bearophile wrote:
> A little quiz. This is related to a recent post of mine in the main D
> newsgroup, but please don't take a look at that post yet. This is the
> original function:
uhm, very sneaky.
I wonder, can there be done smth. on behalf of the language t
Pedro Rodrigues:
> The fact that 'i' and 'j' are deduced to type 'uint' in the second
> version. That's the kind of bug that would keep me up at night.
Almost right answer. i and j are size_t, that is not uint in 64 bit
compilations. Unsigned numbers cause the (i-j) sub-expression to give wrong
On 28-04-2011 16:39, Moritz Warning wrote:
On Thu, 28 Apr 2011 08:02:40 -0400, bearophile wrote:
A little quiz. This is related to a recent post of mine in the main D
newsgroup, but please don't take a look at that post yet. This is the
original function:
uhm, very sneaky.
I wonder, can there
Pedro Rodrigues:
> There sure is: disallow implicit conversion of types.
In this program what are the implicit type conversions that cause the bug?
Bye,
bearophile
On 4/28/11 8:02 PM, bearophile wrote:
A little quiz. This is related to a recent post of mine in the main D
newsgroup, but please don't take a look at that post yet. This is the original
function:
What are unsigned values good for?
bearophile wrote:
Pedro Rodrigues:
The fact that 'i' and 'j' are deduced to type 'uint' in the second
version. That's the kind of bug that would keep me up at night.
Almost right answer. i and j are size_t, that is not uint in 64 bit
compilations. Unsigned numbers cause the (i-j) sub-express
I was away.
Don:
> That would not fix this problem. You're doing arithmetic on unsigned
> values, where overflow doesn't happen.
My enhancement request about integral overflows asks for two compiler switches:
one that turns signed integral overflows (at compile time or run time) into
errors,
11 matches
Mail list logo