Re: pointer bug
From: David Browne (meat_at_hotmail.com)
Date: 03/07/04
- Next message: v-jetan_at_online.microsoft.com: "Re: changing a filename in C#"
- Previous message: Rush: "Using StreamReader when the File Doesn't exist"
- In reply to: agro_r: "pointer bug"
- Next in thread: agro_r: "re:pointer bug"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 6 Mar 2004 23:52:03 -0600
"agro_r" <agro_rachmatullah@yahoo-dot-com.no-spam.invalid> wrote in message
news:404aa796$1_2@Usenet.com...
> I think I've found a bug on Microsoft Visual C# or maybe on the .NET
> Framework itself... Look at this code:
>
> using System;
>
> public class Bar
> {
> public static void Main()
> {
> int[] a = {5, 4, 3, 2, 1};
> unsafe
> {
> fixed(int* ptr = a)
> {
> int* reader = ptr;
> while(true)
> {
> Console.Write("@ 0xX{0:X}is ", (uint)reader);
> Console.WriteLine("{0}", *(reader--));
> }
> }
> }
> }
> }
>
unsafe code isn't guaranteed to throw an exception when you do bad things.
That's why it's unsafe.
Once you dereference reader-1, all bets are off.
David
- Next message: v-jetan_at_online.microsoft.com: "Re: changing a filename in C#"
- Previous message: Rush: "Using StreamReader when the File Doesn't exist"
- In reply to: agro_r: "pointer bug"
- Next in thread: agro_r: "re:pointer bug"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|