Bug 36839

Summary: mcs emits wrong code for char pointer arithmetic
Product: [Mono] Compilers Reporter: Alexander Köplinger [MSFT] <alkpli>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: test.cs

Description Alexander Köplinger [MSFT] 2015-12-10 17:49:30 UTC
Created attachment 14228 [details]
test.cs

Compile attached test.cs with:
> mcs /unsafe test.cs

and run it (with a 64bit Mono!), result is:

>64bit: True
>p:    109800038
>end:   89800038

The pointer wrapped over, which shouldn't be the case.

Running the same code compiled with MS csc produces the expected result:

>64bit: True
>p:    109200038
>end:  189200038

If I cast the "count" variable to long, then the problem goes away on mcs as well.
Comment 1 Marek Safar 2015-12-11 16:56:59 UTC
Fixed in master