public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15508] New: Size evaluation of variable-length array seem to be skipped in some cases.
@ 2004-05-18 20:47 takashi dot yano at nifty dot ne dot jp
  2004-05-18 23:02 ` [Bug c++/15508] " pinskia at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: takashi dot yano at nifty dot ne dot jp @ 2004-05-18 20:47 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-11-11 23:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-18 20:47 [Bug c++/15508] New: Size evaluation of variable-length array seem to be skipped in some cases takashi dot yano at nifty dot ne dot jp
2004-05-18 23:02 ` [Bug c++/15508] " pinskia at gcc dot gnu dot org
2004-05-18 23:32 ` pinskia at gcc dot gnu dot org
2004-05-18 23:32 ` takashi dot yano at nifty dot ne dot jp
2004-05-19  0:22 ` takashi dot yano at nifty dot ne dot jp
2004-05-19  1:15 ` pinskia at gcc dot gnu dot org
2004-05-19  1:25 ` takashi dot yano at nifty dot ne dot jp
2004-05-19  3:05 ` takashi dot yano at nifty dot ne dot jp
2004-05-19  3:12 ` pinskia at gcc dot gnu dot org
2004-05-19  4:12 ` takashi dot yano at nifty dot ne dot jp
2004-05-20 17:49 ` giovannibajo at libero dot it
2004-05-20 22:09 ` pinskia at gcc dot gnu dot org
2004-05-21 17:43 ` takashi dot yano at nifty dot ne dot jp
2004-05-22  8:50 ` takashi dot yano at nifty dot ne dot jp
2004-05-22 14:56 ` bangerth at dealii dot org
2004-08-12  0:23 ` pinskia at gcc dot gnu dot org
2004-11-11 23:41 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).