Skip to content

Commit

Permalink
[642975] Fix initializer of partially static multidimensional arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Oct 8, 2010
1 parent 6e5cb79 commit 0fe5c11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mcs/mcs/expression.cs
Expand Up @@ -5949,7 +5949,6 @@ bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool spec
if (initializers == null)
return true;

only_constant_initializers = true;
for (int i = 0; i < probe.Count; ++i) {
var o = probe [i];
if (o is ArrayInitializer) {
Expand Down Expand Up @@ -6057,6 +6056,8 @@ protected virtual Expression ResolveArrayElement (ResolveContext ec, Expression

protected bool ResolveInitializers (ResolveContext ec)
{
only_constant_initializers = true;

if (arguments != null) {
bool res = true;
for (int i = 0; i < arguments.Count; ++i) {
Expand Down
24 changes: 24 additions & 0 deletions mcs/tests/test-539.cs
@@ -0,0 +1,24 @@
// Compiler options: -optimize
using System;

class Test
{
static int Main ()
{
//switching to a constant fixes the problem
double thisIsCausingTheProblem = 5.0;

double[,] m1 = new double[4, 4] {
{ 1.0, 0.0, 0.0, thisIsCausingTheProblem },
{ 0.0, 1.0, 0.0, thisIsCausingTheProblem },
{ 0.0, 0.0, 1.0, thisIsCausingTheProblem },
{ 0.0, 0.0, 0.0, 1.0 }
};

var r = m1[0, 3];
if (r != 5)
return 1;

return 0;
}
}

0 comments on commit 0fe5c11

Please sign in to comment.