From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e0fa6eae2c537e3d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!q12g2000prb.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: GNAT.Regpat problem. Date: Tue, 22 Mar 2011 12:21:41 -0700 (PDT) Organization: http://groups.google.com Message-ID: <41cae3ac-97b6-4b01-ad73-9ff1ec2fdf86@q12g2000prb.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1300821702 30898 127.0.0.1 (22 Mar 2011 19:21:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 22 Mar 2011 19:21:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q12g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19353 Date: 2011-03-22T12:21:41-07:00 List-Id: On Mar 22, 11:35=A0am, "Peter C. Chapin" wrote: > I'm trying to use regular expressions in a program via the package > GNAT.Regpat. Here is a reduced example: > > with Ada.Text_IO; use Ada.Text_IO; > with GNAT.Regpat; > > procedure Check is > =A0 =A0 Matcher : GNAT.Regpat.Pattern_Matcher(10); > > begin > =A0 =A0 GNAT.Regpat.Compile(Matcher, "^[:space:]*xyzzy$"); > > exception > =A0 =A0 when Storage_Error =3D> > =A0 =A0 =A0 =A0Put_Line("Insufficient space in Pattern_Matcher"); > > end Check; > > The documentation for package GNAT.Regpat says this about the Compile > procedure I think I'm using: "This function [sic] raises Storage_Error if > Matcher is too small to hold the resulting code (i.e. Matcher.Size has to= o > small a value)." > > In the example above the size is intentionally set too small. My program > fails with a PROGRAM_ERROR exception (EXCEPTION_ACCESS_VIOLATION). If I m= ake > the size of the Matcher just 1, the program hangs. If I make the size > something reasonable, the program runs fine. > > So is this an issue with GNAT.Regpat? It seems like it does not honor its > documentation. Perhaps I'm doing something wrong. I'm not sure whether I'm working with the latest version. However, when I took the sources for this package from GNAT 4.5.2 and compiled and ran them (with your test) using a different compiler, a slice assignment in Emit_Class failed due to out-of-range bounds. If that range check were turned off, I can imagine that the result would be havoc. -- Adam