﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
175	Instantiated generic struct layout is reused across different instantiating array sizes	mlbrooks		"In the example, y is supposed to be three bytes long, with a .second field naming the third byte.  But declaring x before y incorretly changes the actual size and layout of y, to be the same as x's.

Note that the types that instante mypair for x and y are different, but they belong to the same equivalence class under array-pointer decay.

Example:
{{{
forall( dtype T1, dtype T2 | sized(T1) | sized(T2) )
struct mypair {
    T1 first;
    T2 second;
};

int main() {

  #ifdef DECLARE_X
    mypair(char[1], char) x @= {};
    printf(""|x| = %ld\n"", sizeof(x));    // expect 2
  #endif

    mypair(char[2], char) y @= {};
    printf(""|y| = %ld\n"", sizeof(y));    // expect 3

    y.second = 0;
    printf(""y.second = %d\n"", y.second); // expect 0

    y.first[1] = 17;                     // in bound of char[2]
    printf(""y.second = %d\n"", y.second); // expect 0
}
}}}

Compiled plain, actual and expected:
{{{
|y| = 3
y.second = 0
y.second = 0
}}}

Compiled -DDECLARE_X, actual:
{{{
|x| = 2
|y| = 2
y.second = 0
y.second = 17
}}}

Compiled -DDECLARE_X, expected:
{{{
|x| = 2
|y| = 3
y.second = 0
y.second = 0
}}}
"	defect	closed	minor	cfa-cc	1.0	fixed		
