[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libreswan-dev
Subject:    Re: [Swan-dev] pointer initialization and fcfcde7422a4805a56a3a4a175271c56fbbbab12
From:       "D. Hugh Redelmeier" <hugh () mimosa ! com>
Date:       2016-07-04 21:03:24
Message-ID: alpine.LRH.2.02.1607041644440.2318 () redclaw ! mimosa ! com
[Download RAW message or body]

| From: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>

| So did their compiler explicitly handle a cast of a 0 value integer to
| a pointer and map it to the "correct" null pointer address value?
| 
| That seems horribly complicated to manage.

Almost always an int to pointer conversion involves a literal 0.  Easy.

Almost no pointers (literal or otherwise) are converted to int.

The part of the standard you quoted refers to a literal 0.

Casting a non-0 literal integer to a pointer type is rare.  Using -1
as a second in-band signal happened sometimes in old code.

Casting a non-literal integer to a pointer is not often meaningful.
Or vice-versa.  It is not common.  But it is legal.  It is usually a
sign of a broken program.  Really low-level programs may do pointer
arithmetic with some integral type.  The standard imposes no
requirements on this.

It is as easy to handle this conversion as it is to handle casting an
int to a float.  From a compiler standpoint, it takes code, not just
painting a new type on the old value.  Since this is rare, who cares?
_______________________________________________
Swan-dev mailing list
Swan-dev@lists.libreswan.org
https://lists.libreswan.org/mailman/listinfo/swan-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic