Changeset 43d9679 for doc/theses/mike_brooks_MMath/background.tex
- Timestamp:
- Aug 11, 2024, 5:33:57 PM (3 months ago)
- Branches:
- master
- Children:
- 0e6aba06, 206ecae
- Parents:
- 774c97e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/background.tex
r774c97e r43d9679 2 2 3 3 Since this work builds on C, it is necessary to explain the C mechanisms and their shortcomings for array, linked list, and string. 4 5 6 \section{Ill-typed expressions} 7 8 C reports many ill-typed expressions as warnings. 9 For example, these attempts to assign @y@ to @x@ and vice-versa are obviously ill-typed. 10 \lstinput{12-15}{bkgd-c-tyerr.c} 11 with warnings: 12 \begin{cfa} 13 warning: assignment to 'float *' from incompatible pointer type 'void (*)(void)' 14 warning: assignment to 'void (*)(void)' from incompatible pointer type 'float *' 15 \end{cfa} 16 Similarly, 17 \lstinput{17-19}{bkgd-c-tyerr.c} 18 with warning: 19 \begin{cfa} 20 warning: passing argument 1 of 'f' from incompatible pointer type 21 note: expected 'void (*)(void)' but argument is of type 'float *' 22 \end{cfa} 23 with a segmentation fault at runtime. 24 Clearly, @gcc@ understands these ill-typed case, and yet allows the program to compile, which seems inappropriate. 25 Compiling with flag @-Werror@, which turns warnings into errors, is often too strong, because some warnings are just warnings, \eg unused variable. 26 In the following discussion, ``ill-typed'' means giving a nonzero @gcc@ exit condition with a message that discusses typing. 27 Note, \CFA's type-system rejects all these ill-typed cases as type mismatch errors. 28 29 % That @f@'s attempt to call @g@ fails is not due to 3.14 being a particularly unlucky choice of value to put in the variable @pi@. 30 % Rather, it is because obtaining a program that includes this essential fragment, yet exhibits a behaviour other than "doomed to crash," is a matter for an obfuscated coding competition. 31 32 % A "tractable syntactic method for proving the absence of certain program behaviours by classifying phrases according to the kinds of values they compute"*1 rejected the program. 33 % The behaviour (whose absence is unprovable) is neither minor nor unlikely. 34 % The rejection shows that the program is ill-typed. 35 % 36 % Yet, the rejection presents as a GCC warning. 37 % *1 TAPL-pg1 definition of a type system 4 38 5 39
Note: See TracChangeset
for help on using the changeset viewer.