Re: Secure Dereference of NULL-Pointer when using list.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 5 Oct 2006, Jinesh K J wrote:

But, let us clear things up before leaving the topic off. With
reference to ISO/IEC 9899:1999(E), the following could be observed:
...
-  value of a void expression shall not be used in any way
-  If an expression of any other type(which included our variable 'a')
is evaluated as a void expression, its value or designator is
discarded.
-  Here there are no side effects( no function call, assignments, etc)

I hope my observations are correct.

You may be right. Reading standards is hairy and I would also consider the interpretation "evaluate the expression and discard the value" valid. Although I'm nitpicking here, say if foo were a hardware register which had a side effect of some sorts when reading it, then the statement *foo; would actually do something even though the value wouldn't be used (better declare foo volatile too to make sure the compiler doesn't optimize it away).

In any case, I wouldn't like to let a line like

*( (char *) 0);

pass by the compiler, whether or not the actual compiler conforms to the standard, whichever the interpretation of the standard may be. It's one of the situations that I would imagine a compiler designer could get wrong, regardless what the standard says...

/Ricard
--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux