[ros-dev] gcc problem or not

Danny Smith dannysmith at clear.net.nz
Wed May 4 09:56:26 CEST 2005



> -----Original Message-----
> From: ros-dev-bounces at reactos.com 
> [mailto:ros-dev-bounces at reactos.com] On Behalf Of Thomas Weidenmueller
> Sent: Wednesday, May 04, 2005 7:16 AM
> To: ReactOS Development List
> Subject: Re: [ros-dev] gcc problem or not
> 
> 
> Hartmut Birr wrote:
> > Hi,
> > 
> > I was always the opinion  that the examination of a test condition 
> > stops if the result can not change again. A test condition 
> like this:
> > 
> > if (pointer == NULL || pointer->member == 0)
> > 
> > should never access pointer->member if pointer is zero. 
> Compared with 
> > the code above, it is possible that gcc build the result from the 
> > right side of the OR statement. This may hit a page fault. 
> Is this a 
> > bug in gcc?
> 
> It should definitely not dereference if it's NULL. The 
> conditions should 
> be checked from left to right in this case, no matter how much was 
> optimized.
> 

To be safe, you might also check
BadReadPtr(pointer,sizeof(struct_pointed_to)).  The pointer may be
undefined, rather than NULL.

Danny

> Thomas
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.com http://reactos.com:8080/mailman/listinfo/ros-dev
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005
>  
> 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005
 



More information about the Ros-dev mailing list