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]

[Bug c++/15508] New: Size evaluation of variable-length array seem to be skipped in some cases.


Versions with the problem:
2.96 (readhat)
3.3.1 (cygming spetial)

Versions without the problem:
2.95.2 19991024 (release)
2.95.3 20010315 (release) [FreeBSD]

Environment:
Red Hat Linux 7.3 2.96-112 (i386-redhat-linux)
CYGWIN_NT-5.1 1.5.9(0.112/4/2) 2004-03-18 23:05 i686

How to reproduce:
% g++ -Wall g++_bug.cc
% ./a.out
1	1
2	2
3	3
4	4
5	4
a.out: g++_bug.cc:11: void func (int): Assertion `a[1] - a[0] == r' failed.
Abort (core dumped)
% 

Expected result:
% ./a.out
1	1
2	2
3	3
4	4
5	5
6	6
7	7
8	8
9	9
% 

Source Code:

// Filename: g++_bug.cc
#include <iostream>
#include <cassert>

void func(int r)
{
	int (*a)[r] = new int [2][r];

	if (r<5) a[1][0] = 0;

	std::cout << r << '\t' << a[1] - a[0] << std::endl;
	assert( a[1] - a[0] == r);

	delete [] a;
}

int main()
{
	for (int i=1; i<10; i++) func(i);
	return 0;
}

-- 
           Summary: Size evaluation of variable-length array seem to be
                    skipped in some cases.
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: takashi dot yano at nifty dot ne dot jp
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15508


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