Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22122

HP-UX cc uses a default setting to allow null dereferences, is that possible in gcc with RHEL?

$
0
0

From the HPUX cc, c89 - C compiler man page:

  -z             Do not bind anything to address zero.  This option
                 allows runtime detection of null pointers.  See the
                 note on pointers below.

  -Z             Allow dereferencing of null pointers.  See the note on
                 pointers below.  The -z and -Z are linker options.  See
                 ld(1) for more details.

Then from ld(1):

The default value of the -Z/-z option is -Z.

This means that, by default, any C program compiled with this version of cc on HPUX that dereferences a null pointer will read the value as 0 and not segfault. There is no option for this with gcc or cc on RHEL. Does anyone know how I would compile a C program with an option like this on RHEL (to allow null dereferece)? I know this is a terrible coding practice and I will not be using it to create new code. Thank you.


Viewing all articles
Browse latest Browse all 22122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>