21st Century C by Ben Klemens

21st Century C by Ben Klemens

Author:Ben Klemens [Klemens, Ben]
Language: eng
Format: epub, mobi, pdf
Tags: c, o'reilly
Publisher: O'Reilly Media
Published: 2014-10-12T18:30:00+00:00


#include <stdio.h> int main(){ int *var; int const **constptr = &var; // the line that sets up the failure int const fixed = 20; *constptr = &fixed; // 100% valid *var = 30; printf("x=%i y=%i\n", fixed, *var); }

Figure 8-2. The links among the variables in Example 8-7

We would never allow int *var to point directly at int const fixed. We only managed it via a sleight-of-pointer where var winds up implicitly pointing to fixed without explicitly stating it.

Your Turn: Is it possible to cause a failure of const like this one, but where the disallowed type cast happens over the course of a function call, as per the Iggy Pop detector?



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.