This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/6956: when the given code is compiled with optimization > 0, it fails


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]