<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>silly pointer question - C++ - tribe.net</title>
    <link>http://cpp.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4?format=rss</link>
    <description>Tribe.net. Local Connections</description>
    <item>
      <title>silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#11e2e238-c4ec-41a3-b9c3-a34bbdbdbe98</link>
      <description>What's this do? I assume it crashes the app, if not the whole system, but knowing very little about memory architecture I could see it doing something weird like wipe my BIOS. So I'm afraid to compile it and find out. Oh, and tribe doesn't like my indents, sorry.&#xD;
&#xD;
void main()&#xD;
{&#xD;
 for (int x=0; 1; x++)&#xD;
  *x=0;&#xD;
}</description>
      <pubDate>Wed, 18 Feb 2004 23:05:03 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#11e2e238-c4ec-41a3-b9c3-a34bbdbdbe98</guid>
      <dc:creator>StFiend</dc:creator>
      <dc:date>2004-02-18T23:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#f1516ab8-f3ba-4a90-8a6f-959f838a45bf</link>
      <description>Or can I even use the reference operator with a variable not explicitly defined as a pointer? Obviously I've not yet done any serious C coding...</description>
      <pubDate>Wed, 18 Feb 2004 23:08:23 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#f1516ab8-f3ba-4a90-8a6f-959f838a45bf</guid>
      <dc:creator>StFiend</dc:creator>
      <dc:date>2004-02-18T23:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#d3a8b58c-e65f-4a3f-bfff-3400af4955fb</link>
      <description>You can't use an int as a pointer.  To work, it'd have to be something like:&#xD;
for (int x=0; 1; x++) &#xD;
{&#xD;
	char *loc = (char*)x;&#xD;
	*loc=0; &#xD;
}&#xD;
&#xD;
As to what it's do, depends on the operating system.  Might crash or hang Win 95/98/Me but NT variants and UNIX/Linux variants wil protect OS memory.</description>
      <pubDate>Wed, 18 Feb 2004 23:40:05 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#d3a8b58c-e65f-4a3f-bfff-3400af4955fb</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-18T23:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#5f38b319-3637-40e8-9a28-dacbc7448c8f</link>
      <description>why wouldn't that give a syntax error or a trivial reassignment depending upon compiler?  you are just dereferencing the memory location of variable "x" right?  &#xD;
&#xD;
and even if it doesn't, I could see:&#xD;
&#xD;
&amp;amp;x = 0; &#xD;
&#xD;
which would should take the memory space for "x" and set it to NULL while it should still be storing a value, and that I could see would give a segfault.  Kind of curious, its stuff like this that makes C/C++ mystifying, so any input would be much appreciated.</description>
      <pubDate>Thu, 19 Feb 2004 03:47:18 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#5f38b319-3637-40e8-9a28-dacbc7448c8f</guid>
      <dc:creator>Chris</dc:creator>
      <dc:date>2004-02-19T03:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#2caadcfc-b5b4-44b1-a546-8bd0b91e38c9</link>
      <description>I got an illegal indirection error from Visual Studio, wouldn't even compile.&#xD;
&#xD;
The "&amp;amp;x = 0" results in "left operand must be l-value" error.  l-value refers to the left side of an equation.  Not sure if that's ANSII C++ or a Microsoft improvisation.&#xD;
&#xD;
Maybe because you're trying to alter the location of a real variable whose space was allocated by the compiler/loader and&#xD;
not just change the pointer...</description>
      <pubDate>Thu, 19 Feb 2004 04:00:10 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#2caadcfc-b5b4-44b1-a546-8bd0b91e38c9</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-19T04:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#92d4c59d-5b2d-4dc9-8b8a-bb2361c8bd5f</link>
      <description>well, as I was walking home, I realized the real villain was :&#xD;
&#xD;
for(int x=0; 1; x++)&#xD;
&#xD;
didn't realize what that "1" would do for a little bit.  Now I see more of the problem.  &#xD;
&#xD;
I think the l-value is ANSI, and it makes sense, you aren't allowed to reassign registers to fixed variables.  So all is right with the world.  still though, I am curious, why would :&#xD;
&#xD;
for(int x=0; 1; i++)&#xD;
*x=0;&#xD;
&#xD;
cause any problem? aside from the infinite loop that would kick in that is?</description>
      <pubDate>Thu, 19 Feb 2004 08:12:41 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#92d4c59d-5b2d-4dc9-8b8a-bb2361c8bd5f</guid>
      <dc:creator>Chris</dc:creator>
      <dc:date>2004-02-19T08:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#7ea1eb15-9278-40b5-935a-1fbfcf5b963e</link>
      <description>&gt;for(int x=0; 1; i++) &#xD;
&gt;  *x=0; &#xD;
&gt;&#xD;
&gt;cause any problem? aside from the infinite loop that would &gt;kick in that is? &#xD;
&#xD;
Because you can only use the indirection operator "*" on pointer data types.  You can change the location that a pointer references but you can't change the location that a non-pointer references.&#xD;
&#xD;
   Don</description>
      <pubDate>Thu, 19 Feb 2004 14:02:43 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#7ea1eb15-9278-40b5-935a-1fbfcf5b963e</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-19T14:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#b25d2889-224f-4538-8b7e-ef21872261f2</link>
      <description>Gah, and I thought I was starting to grok pointers.&#xD;
&#xD;
At least my question turned out to be nontrivial...</description>
      <pubDate>Thu, 19 Feb 2004 17:16:15 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#b25d2889-224f-4538-8b7e-ef21872261f2</guid>
      <dc:creator>StFiend</dc:creator>
      <dc:date>2004-02-19T17:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#c1598cae-cadd-4ecb-bae8-96e9e0e26fef</link>
      <description>look up Kernighan and Ritchie online, it should be free.  if I remember correctly, they have some horrific examples of pointer expressions that if you can figure out help in making sense of them.</description>
      <pubDate>Thu, 19 Feb 2004 17:21:07 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#c1598cae-cadd-4ecb-bae8-96e9e0e26fef</guid>
      <dc:creator>Chris</dc:creator>
      <dc:date>2004-02-19T17:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#19eff743-3fb0-4a26-9603-6e3f17f44e46</link>
      <description>Another thing could is to take an Assembly Language Programming class.  Getting down to the raw bits and bytes and working with different reference modes is a big help in groking what's going on.&#xD;
&#xD;
And the debugger is your friend.</description>
      <pubDate>Thu, 19 Feb 2004 17:25:26 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#19eff743-3fb0-4a26-9603-6e3f17f44e46</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-19T17:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#1b5b40b0-b7b3-43b9-8159-119683cbc199</link>
      <description>BTW, I was curious whether a different error would be thrown at address 0x0 than, say, at 0x5000 because NT variants tend to use the first chunk (1024 or 2048 bytes, I think) of a process's virtual address space as kind of a canary in a coal mine:  they're never allocated legitimately and ANY attempt to read/write there will be an error automatically.&#xD;
&#xD;
But the error looks the same...</description>
      <pubDate>Thu, 19 Feb 2004 17:37:22 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#1b5b40b0-b7b3-43b9-8159-119683cbc199</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-19T17:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#cee6bf70-8a3d-4a40-91a7-73267f460fa0</link>
      <description>That was actually what I was getting at with my question, wondering what the memory address values actually correspond to, practically speaking. Whether the addresses are absolute for the machine or relative to each process, that sort of thing. (Though the pointer education is handy too, of course.) Now what's this, you're saying my OS uses an entire megabyte per process on nothing at all? Why is that?</description>
      <pubDate>Thu, 19 Feb 2004 18:18:14 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#cee6bf70-8a3d-4a40-91a7-73267f460fa0</guid>
      <dc:creator>StFiend</dc:creator>
      <dc:date>2004-02-19T18:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: silly pointer question</title>
      <link>http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#95f8dcaa-08b3-471b-8994-9a5d3a7f79f2</link>
      <description>It's OS specific.  Not that familiar with UNIX but this link leads to info about how some Windows variants map out your virtual address space.  Looks like it's the first 64k that you can't touch but that's virtual memory, not your machine's physical memory going to waste:&#xD;
http://tinyurl.com/2wm3y&#xD;
&#xD;
If you're interested, this one looks at how the loader and Windows run executables:&#xD;
http://tinyurl.com/at4w</description>
      <pubDate>Thu, 19 Feb 2004 18:34:01 GMT</pubDate>
      <guid isPermaLink="false">http://CPP.tribe.net/thread/75e909fa-6739-4fab-9d0c-e94d683f77d4#95f8dcaa-08b3-471b-8994-9a5d3a7f79f2</guid>
      <dc:creator>Genghis "Doh!"</dc:creator>
      <dc:date>2004-02-19T18:34:01Z</dc:date>
    </item>
  </channel>
</rss>



