Why does "*" cause my tiny regextester program to crash?

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jan 31 12:43:46 PST 2011

On 31.01.2011 4:57, Alex Folland wrote:
> I wrote this little program to test for regular expression matches.  I 
> compiled it with in Windows with DMD 2.051 through Visual Studio 2010 
> with Visual D.  It crashes if regexbuf is just the single character, 
> "*".  Why?  Shouldn't it match the entire string?
> Visual Studio's debug output is this:
> First-chance exception at 0x76fde124 in regextester.exe: 0xE0440001: 
> 0xe0440001.
> The program '[5492] regextester.exe: Native' has exited with code 1 
> (0x1).
To shed some light on this output.
After using Visual D quite a lot I can tell you that this output 
*doesn't* mean the program crushed (in terms of segfault etc.).  All it 
means is that there is uncaught exception, which is quite reasonable. 
Regexp parsing function throws when it detects wrong pattern.  In 
general, when you are uncertain on what the **uk is going on I suggest 
to wrap suspicious code with :
      ... //code
}catch(Exception e){
to see what's the errors are.

with lone "*" in regexp output would be :
object.Exception: *+? not allowed in atom
not very detailed perhaps but gives a hint ;)

Dmitry Olshansky

More information about the Digitalmars-d-learn mailing list