home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.development      Operating system development chatter      4,255 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,611 of 4,255   
   mutazilah@gmail.com to Alexei A. Frounze   
   Re: clang bug   
   01 Mar 23 22:47:08   
   
   From: muta...@gmail.com   
      
   On Thursday, March 2, 2023 at 1:34:09 PM UTC+8, Alexei A. Frounze wrote:   
   > On Wednesday, March 1, 2023 at 8:53:51 PM UTC-8, muta...@gmail.com wrote:    
   > > Ok, I'm back on my computer now and was able to raise a bug report:    
   > >    
   > > https://github.com/llvm/llvm-project/issues/61112    
   > >    
   > > BFN. Paul.   
   > Without looking any further, you're taking address of a parameter (p),    
   > and doing pointer arithmetic on it. The only valid arithmetic here    
   > would be adding 0 or 1, but not 5, 6 or 7. But even if you add 1 to &p,    
   > you aren't allowed to dereference it (as in *(&p + 1)).    
   > You can only subtract the 1 back (as in (&p + 1) - 1) or compute    
   > a difference of that and &p (as in (&p + 1) - &p or the other way around).    
   > Your shady pointer manipulation is undefined behavior and    
   > I almost guarantee your clang bug being soon closed as invalid.    
   >    
   > Write clean code. OK, write cleaner code. Maybe, refresh your ANSI C    
   > to get there.   
      
   "undefined behavior" shouldn't mean "let's leave the stack   
   uninitialized, and not even issue a warning". It just means   
   you can't guarantee what the result will be.   
      
   But you can still give a sensible result.   
      
   In this case, I am trying to inspect the stack. I'm using   
   knowledge of the x86 as to what the stack looks like,   
   and the calling convention.   
      
   Yes. That code won't work on every platform in the world.   
      
   But it should work perfectly fine when I know the layout.   
      
   It is not in the spirit of C to catch every undefined behavior   
   and throw an error. And in this case, even throwing an error   
   would be better than silent failure and garbage.   
      
   Even if setting a pointer to the arbitrary value 0xb8000 and   
   indexing up a 1000 bytes is undefined behavior, doesn't   
   mean it should be disallowed either.   
      
   BFN. Paul.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca