optimization/6956: when the given code is compiled with optimization > 0, it fails
spamjunk@stny.rr.com
spamjunk@stny.rr.com
Fri Jun 7 07:46:00 GMT 2002
>Number: 6956
>Category: optimization
>Synopsis: when the given code is compiled with optimization > 0, it fails
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jun 07 07:45:59 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: spamjunk@stny.rr.com
>Release: unknown-1.0
>Organization:
>Environment:
dos/windows
>Description:
#include <cstdio>
using namespace std;
template<class T, int I>
struct A {
A() {}
typedef T array[I];
struct B {
array a;
};
static B X()
{
const B b = {{0, 0, 5}};
return b;
}
};
typedef A<int, 5> C;
int main()
{
printf("%d\n", C::X().a[2]);
return 0;
}
This code fails with optimization turned on. If b is made a static constant, it doesn't fail.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list