gcc/gcc
Arnaud Charlet 8ed7930e45 [multiple changes]
2013-01-02  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_attr.adb (Analyze_Attribute): Skip the special _Parent
	scope generated for subprogram inlining purposes while trying
	to locate the enclosing function.
	* sem_prag.adb (Analyze_Pragma): Preanalyze the boolean
	expression of pragma Postcondition when the pragma comes from
	source and appears inside a subprogram body.

2013-01-02  Thomas Quinot  <quinot@adacore.com>

	* switch-c.adb, fe.h, back_end.adb: Enable generation of instantiation
	information in debug info unconditionally when using -fdump-scos,
	instead of relying on a separate command line switch -fdebug-instances.

2013-01-02  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch12.adb: Additional refinement of predicate.

2013-01-02  Vincent Celier  <celier@adacore.com>

	* vms_data.ads: Remove incorrect spaces at end of descriptions
	of qualifiers for single switch.

2013-01-02  Ben Brosgol  <brosgol@adacore.com>

	* gnat_rm.texi: Minor edits / wordsmithing in section on pragma
	Check_Float_Overflow.

2013-01-02  Thomas Quinot  <quinot@adacore.com>

	* sprint.adb (Sprint_Node_Actual): Do not add extra parens for
	a conditional expression (CASE or IF expression) that already
	has parens. Also omit ELSE keyword for an IF expression without
	an ELSE part.

2013-01-02  Thomas Quinot  <quinot@adacore.com>

	* gnat1drv.adb (Adjust_Global_Switches): Adjust back-end
	flag_debug_instances here, after front-end switches have been
	processed.

From-SVN: r194792
2013-01-02 11:38:18 +01:00
..
ada [multiple changes] 2013-01-02 11:38:18 +01:00
c re PR c++/55619 (Chromium build fails with: error: memory input is not directly addressable) 2012-12-20 11:41:47 +01:00
c-family Before this patch... 2012-12-27 01:58:06 +00:00
common
config rs6000.c (rs6000_deligitimze_address): Do not delegitimize TLS addresses on AIX. 2012-12-27 12:53:17 -05:00
cp rtti.c (LONGPTR_T): New helper-macro. 2012-12-28 22:49:59 +01:00
doc Before this patch... 2012-12-27 01:58:06 +00:00
fortran re PR fortran/55692 (ICE on incorrect use of ASSOCIATED function) 2012-12-28 16:14:45 +01:00
ginclude
go compiler: Error if name defined in both package and file blocks. 2012-12-21 22:23:23 +00:00
java
lto
objc
objcp
po
testsuite newunit_3.f90: Add dg-do run. 2013-01-02 03:46:44 +00:00
ABOUT-GCC-NLS
acinclude.m4
aclocal.m4
addresses.h
alias.c re PR target/54781 (ICE in refs_may_alias_p_1, at tree-ssa-alias.c:1124) 2012-12-17 14:55:53 +00:00
alias.h
alloc-pool.c
alloc-pool.h
asan.c re PR sanitizer/55508 (many test cases fail using -fsanitize=address with internal compiler error: in expand_call_tm) 2012-12-13 00:05:23 +01:00
asan.h
attribs.c
auto-inc-dec.c
BASE-VER
basic-block.h
bb-reorder.c
bb-reorder.h
bitmap.c bitmap.c (struct bitmap_descriptor): Remove forward declaration. 2012-12-13 10:02:39 +00:00
bitmap.h bitmap.c (struct bitmap_descriptor): Remove forward declaration. 2012-12-13 10:02:39 +00:00
bt-load.c
builtin-attrs.def re PR sanitizer/55508 (many test cases fail using -fsanitize=address with internal compiler error: in expand_call_tm) 2012-12-13 00:05:23 +01:00
builtin-types.def
builtins.c
builtins.def
builtins.h
caller-save.c
calls.c
cfg-flags.def
cfg.c
cfganal.c
cfgbuild.c
cfgcleanup.c
cfgexpand.c
cfghooks.c re PR rtl-optimization/55740 (ICE in verify_loop_structure, at cfgloop.c:1582, error: loop 2's header does not belong directly to it) 2012-12-20 12:45:48 +00:00
cfghooks.h
cfgloop.c
cfgloop.h
cfgloopanal.c
cfgloopmanip.c re PR middle-end/54838 (ICE: in merge_latch_edges, at cfgloop.c:678 with -ftracer) 2012-12-18 14:39:49 +00:00
cfgrtl.c
cgraph.c * cgraph.c (verify_cgraph_node): Don't allocate/free visited_nodes set. 2012-12-27 00:10:14 +00:00
cgraph.h re PR lto/54728 (ICE in input_gimple_stmt, at gimple-streamer-in.c:254) 2012-12-22 23:27:49 +00:00
cgraphbuild.c
cgraphclones.c
cgraphunit.c
ChangeLog * ipa-inline-analysis.c: Fix formatting. 2013-01-01 16:22:10 +00:00
ChangeLog-1997
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog.dataflow
ChangeLog.graphite
ChangeLog.lib
ChangeLog.ptr
ChangeLog.tree-ssa
ChangeLog.tuples
cif-code.def
collect2-aix.c
collect2-aix.h
collect2.c
collect2.h
combine-stack-adj.c
combine.c target.def: Define canonicalize_comparison hook. 2012-12-19 12:39:17 +00:00
common.opt
compare-elim.c
conditions.h
config.build
config.gcc
config.host
config.in
configure re PR driver/55202 (Building a combined tree is broken for LTO) 2012-12-20 16:57:18 +01:00
configure.ac re PR driver/55202 (Building a combined tree is broken for LTO) 2012-12-20 16:57:18 +01:00
convert.c
convert.h
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
coretypes.h
coverage.c re PR gcov-profile/55650 (Firefox profiledbuild: libxul.so: cannot map zero-fill pages: Cannot allocate memory) 2012-12-13 11:11:39 +01:00
coverage.h
cppbuiltin.c
cppbuiltin.h
cppdefault.c
cppdefault.h
cprop.c re PR middle-end/52996 (ice in verify_loop_structure, at cfgloop.c:1567) 2012-12-21 14:33:59 +00:00
cse.c
cselib.c
cselib.h
cstamp-h.in
data-streamer-in.c
data-streamer-out.c
data-streamer.c
data-streamer.h
DATESTAMP Daily bump. 2013-01-02 00:18:41 +00:00
dbgcnt.c
dbgcnt.def
dbgcnt.h
dbxout.c
dbxout.h
dce.c
dce.h
ddg.c
ddg.h
debug.c
debug.h
defaults.h
DEV-PHASE
df-core.c
df-problems.c
df-scan.c
df.h
dfp.c
dfp.h
diagnostic-core.h
diagnostic.c
diagnostic.def
diagnostic.h
dojump.c
dominance.c
domwalk.c
domwalk.h
double-int.c
double-int.h re PR bootstrap/54659 (Bootstrap with --disable-nls broken under Windows) 2012-12-21 14:33:13 +00:00
dse.c
dumpfile.c dumpfile.h (enum tree_dump_index): Remove TDI_vcg. 2012-12-12 13:17:27 +00:00
dumpfile.h dumpfile.h (enum tree_dump_index): Remove TDI_vcg. 2012-12-12 13:17:27 +00:00
dwarf2asm.c
dwarf2asm.h
dwarf2cfi.c
dwarf2out.c re PR debug/55730 (ICE in mem_loc_descriptor, at dwarf2out.c:12725) 2012-12-19 13:16:56 +01:00
dwarf2out.h
emit-rtl.c
emit-rtl.h
errors.c
errors.h
et-forest.c
et-forest.h
except.c
except.h
exec-tool.in
explow.c
expmed.c
expmed.h
expr.c re PR rtl-optimization/55630 (FAIL: g++.dg/pr48660.C -std=c++98 (internal compiler error)) 2012-12-16 10:02:37 +00:00
expr.h
file-find.c
file-find.h
final.c
fixed-value.c
fixed-value.h
flag-types.h
flags.h
fold-const.c
fp-test.c
FSFChangeLog
FSFChangeLog.10
FSFChangeLog.11
function.c
function.h
fwprop.c
gcc-ar.c
gcc-plugin.h
gcc.c
gcc.h
gcov-dump.c
gcov-io.c Fix PR gcov-profile/55734 by using methods from hwint.c instead of builtins... 2012-12-20 14:31:09 +00:00
gcov-io.h
gcov-iov.c
gcov.c
gcse.c
gcse.h
gdbinit.in
genattr-common.c
genattr.c
genattrtab.c
genautomata.c
gencheck.c
genchecksum.c
gencodes.c
genconditions.c
genconfig.c
genconstants.c
genemit.c
genenums.c
genextract.c
genflags.c
gengenrtl.c
gengtype-lex.l
gengtype-parse.c
gengtype-state.c
gengtype.c
gengtype.h
genhooks.c
genmddeps.c
genmddump.c
genmodes.c
genmultilib
genopinit.c
genoutput.c
genpeep.c
genpreds.c
genrecog.c
gensupport.c
gensupport.h
ggc-common.c
ggc-internal.h
ggc-none.c
ggc-page.c
ggc-zone.c
ggc.h
gimple-fold.c
gimple-fold.h
gimple-iterator.c
gimple-low.c
gimple-pretty-print.c
gimple-pretty-print.h
gimple-ssa-strength-reduction.c
gimple-streamer-in.c
gimple-streamer-out.c
gimple-streamer.h
gimple.c
gimple.def
gimple.h
gimplify.c re PR middle-end/55750 (-( in expand_expr_addr_expr_1, at expr.c:7646) 2012-12-20 19:13:56 +01:00
glimits.h
godump.c
graph.c graph.c: Include sbitmap.h and cfgloop.h. 2012-12-12 13:21:41 +00:00
graph.h
graphds.c
graphds.h
graphite-blocking.c
graphite-clast-to-gimple.c
graphite-clast-to-gimple.h
graphite-dependences.c
graphite-interchange.c
graphite-optimize-isl.c
graphite-poly.c
graphite-poly.h
graphite-scop-detection.c
graphite-scop-detection.h
graphite-sese-to-poly.c
graphite-sese-to-poly.h
graphite.c
gsstruct.def
gstab.h
gsyms.h
gsyslimits.h
gtm-builtins.def
haifa-sched.c
hard-reg-set.h
hash-table.c
hash-table.h
highlev-plugin-common.h
hooks.c
hooks.h
host-default.c
hosthooks-def.h
hosthooks.h
hw-doloop.c
hw-doloop.h
hwint.c
hwint.h
ifcvt.c
incpath.c
incpath.h
init-regs.c
input.c
input.h
insn-addr.h
insn-notes.def
internal-fn.c
internal-fn.def
internal-fn.h
intl.c
intl.h
ipa-cp.c
ipa-inline-analysis.c * ipa-inline-analysis.c: Fix formatting. 2013-01-01 16:22:10 +00:00
ipa-inline-transform.c
ipa-inline.c
ipa-inline.h
ipa-prop.c re PR lto/55736 (lto ICE: tree code ''junl is not supported in LTO streams) 2012-12-19 13:53:18 +00:00
ipa-prop.h
ipa-pure-const.c
ipa-ref-inline.h
ipa-ref.c
ipa-ref.h
ipa-reference.c
ipa-reference.h
ipa-split.c
ipa-utils.c
ipa-utils.h
ipa.c
ira-build.c
ira-color.c
ira-conflicts.c
ira-costs.c
ira-emit.c
ira-int.h
ira-lives.c
ira.c re PR bootstrap/54128 (GCC does not bootstrap on little endian mips due to mis-compare on tree-data-ref.c) 2012-12-21 18:54:00 +00:00
ira.h
is-a.h
jump.c
langhooks-def.h
langhooks.c
langhooks.h
LANGUAGES
lcm.c
libfuncs.h
limitx.h
limity.h
lists.c
loop-doloop.c
loop-init.c re PR middle-end/54838 (ICE: in merge_latch_edges, at cfgloop.c:678 with -ftracer) 2012-12-18 14:39:49 +00:00
loop-invariant.c
loop-iv.c
loop-unroll.c
loop-unswitch.c
lower-subreg.c
lower-subreg.h
lra-assigns.c re PR inline-asm/55775 (ICE when building pari) 2012-12-21 21:20:48 +00:00
lra-coalesce.c
lra-constraints.c re PR inline-asm/55775 (ICE when building pari) 2012-12-21 21:20:48 +00:00
lra-eliminations.c
lra-int.h re PR inline-asm/55775 (ICE when building pari) 2012-12-21 21:20:48 +00:00
lra-lives.c
lra-spills.c
lra.c
lra.h
lto-cgraph.c re PR gcov-profile/55674 (>20% size increase of lto/pgo binaries since r193747) 2012-12-14 15:10:45 +00:00
lto-compress.c
lto-compress.h
lto-opts.c
lto-section-in.c
lto-section-out.c
lto-streamer-in.c
lto-streamer-out.c re PR lto/54728 (ICE in input_gimple_stmt, at gimple-streamer-in.c:254) 2012-12-22 23:27:49 +00:00
lto-streamer.c
lto-streamer.h
lto-symtab.c
lto-wrapper.c
machmode.def
machmode.h
main.c
Makefile.in * Makefile.in: Fix bitmap.o dependencies. 2012-12-13 10:38:43 +00:00
mcf.c
mkconfig.sh
mode-classes.def
mode-switching.c
modulo-sched.c
omega.c
omega.h
omp-builtins.def
omp-low.c
ONEWS
opt-functions.awk
opt-gather.awk
opt-include.awk
opt-read.awk
optabs.c * optabs.c (expand_atomic_store): Elide redundant model test. 2012-12-14 08:24:48 -08:00
optabs.def
optabs.h
optc-gen.awk
optc-save-gen.awk
opth-gen.awk
opts-common.c
opts-diagnostic.h
opts-global.c
opts.c
opts.h
output.h varasm.c (bss_initializer_p): Remove static. 2012-12-21 12:25:57 -05:00
params.c
params.def
params.h
passes.c
plugin.c
plugin.def
plugin.h
pointer-set.c
pointer-set.h
postreload-gcse.c
postreload.c
predict.c
predict.def
predict.h
prefix.c
prefix.h
pretty-print.c
pretty-print.h
print-rtl.c
print-tree.c
profile.c
profile.h
read-md.c
read-md.h
read-rtl.c
README.Portability
real.c
real.h
realmpfr.c
realmpfr.h re PR bootstrap/54659 (Bootstrap with --disable-nls broken under Windows) 2012-12-21 14:33:13 +00:00
recog.c
recog.h
ree.c
reg-notes.def
reg-stack.c
regcprop.c
reginfo.c
regmove.c
regrename.c
regrename.h
regs.h
regset.h
regstat.c
reload1.c
reload.c
reload.h
reorg.c
resource.c
resource.h
rtl-error.c
rtl-error.h
rtl.c
rtl.def
rtl.h
rtlanal.c rtlanal.c (volatile_insn_p): Delete commented out code. 2012-12-21 21:38:11 +00:00
rtlhooks-def.h re PR rtl-optimization/55717 (ICE in form_sum, at reload.c:5400) 2012-12-18 11:50:47 +01:00
rtlhooks.c re PR rtl-optimization/55717 (ICE in form_sum, at reload.c:5400) 2012-12-18 11:50:47 +01:00
sanitizer.def re PR sanitizer/55508 (many test cases fail using -fsanitize=address with internal compiler error: in expand_call_tm) 2012-12-13 00:05:23 +01:00
sbitmap.c re PR target/55562 (FAIL: gcc.dg/sms-* on powerpc*-*-*) 2012-12-18 22:40:29 +01:00
sbitmap.h
sched-deps.c
sched-ebb.c
sched-int.h
sched-rgn.c
sched-vis.c
sdbout.c
sdbout.h
sel-sched-dump.c
sel-sched-dump.h
sel-sched-ir.c
sel-sched-ir.h
sel-sched.c
sel-sched.h
sese.c
sese.h
simplify-rtx.c re PR rtl-optimization/55717 (ICE in form_sum, at reload.c:5400) 2012-12-18 11:50:47 +01:00
sparseset.c
sparseset.h
sreal.c
sreal.h
ssaexpand.h
stab.def
stack-ptr-mod.c
statistics.c
statistics.h
stmt.c
stor-layout.c
store-motion.c
streamer-hooks.c
streamer-hooks.h
stringpool.c
symtab.c
sync-builtins.def
system.h re PR bootstrap/54659 (Bootstrap with --disable-nls broken under Windows) 2012-12-21 14:33:13 +00:00
target-def.h
target-globals.c
target-globals.h
target-hooks-macros.h
target.def * target.def (supports_function_versions): Fix typo. 2012-12-27 10:04:51 +00:00
target.h
targhooks.c rtlanal.c (volatile_insn_p): Delete commented out code. 2012-12-21 21:38:11 +00:00
targhooks.h targhooks.h (default_canonicalize_comparison): Fix prototype. 2012-12-19 14:38:10 +00:00
timevar.c
timevar.def
timevar.h
tlink.c
toplev.c
toplev.h
tracer.c
trans-mem.c
trans-mem.h
tree-affine.c
tree-affine.h
tree-browser.c
tree-browser.def
tree-call-cdce.c
tree-cfg.c dumpfile.h (enum tree_dump_index): Remove TDI_vcg. 2012-12-12 13:17:27 +00:00
tree-cfgcleanup.c
tree-chrec.c
tree-chrec.h re PR tree-optimization/55687 (ICE in hide_evolution_in_other_loops_than_loop, at tree-chrec.c:716) 2012-12-14 12:57:27 +00:00
tree-complex.c
tree-data-ref.c
tree-data-ref.h
tree-dfa.c
tree-diagnostic.c
tree-diagnostic.h
tree-dump.c
tree-dump.h
tree-eh.c
tree-emutls.c
tree-flow-inline.h
tree-flow.h
tree-if-conv.c
tree-inline.c re PR debug/55665 (Missing DW_TAG_lexical_block PC range) 2012-12-13 00:19:32 +01:00
tree-inline.h
tree-into-ssa.c
tree-iterator.c
tree-iterator.h
tree-loop-distribution.c
tree-mudflap.c re PR libmudflap/53952 (FAIL: libmudflap.c++/pass55-frag.cxx ( -O[123]) execution test) 2012-12-15 10:25:15 +00:00
tree-mudflap.h
tree-nested.c
tree-nomudflap.c
tree-nrv.c
tree-object-size.c
tree-optimize.c
tree-outof-ssa.c
tree-parloops.c
tree-pass.h
tree-phinodes.c
tree-predcom.c
tree-pretty-print.c
tree-pretty-print.h
tree-profile.c
tree-scalar-evolution.c re PR middle-end/55555 (miscompilation at -O2 (number_of_iterations)) 2012-12-18 13:12:34 +00:00
tree-scalar-evolution.h
tree-sra.c re PR tree-optimization/55355 (internal compiler error: in tree_low_cst, at tree.c:6415) 2012-12-21 23:06:38 +01:00
tree-ssa-address.c
tree-ssa-alias.c
tree-ssa-alias.h
tree-ssa-ccp.c
tree-ssa-coalesce.c re PR other/54324 (GCC install document does not list minimum required g++ version) 2012-12-18 15:26:27 +00:00
tree-ssa-copy.c
tree-ssa-copyrename.c
tree-ssa-dce.c
tree-ssa-dom.c
tree-ssa-dse.c
tree-ssa-forwprop.c
tree-ssa-ifcombine.c
tree-ssa-live.c
tree-ssa-live.h
tree-ssa-loop-ch.c
tree-ssa-loop-im.c
tree-ssa-loop-ivcanon.c re PR tree-optimization/55684 (ICE in remove_redundant_iv_tests, at tree-ssa-loop-ivcanon.c:559) 2012-12-14 13:35:03 +00:00
tree-ssa-loop-ivopts.c re PR middle-end/55481 (-O2 generates a wrong-code infinite loop in C++Benchmark's simple_types_constant_folding int8 xor test) 2012-12-12 13:07:19 +00:00
tree-ssa-loop-manip.c
tree-ssa-loop-niter.c re PR bootstrap/54659 (Bootstrap with --disable-nls broken under Windows) 2012-12-21 14:33:13 +00:00
tree-ssa-loop-prefetch.c
tree-ssa-loop-unswitch.c
tree-ssa-loop.c
tree-ssa-math-opts.c
tree-ssa-operands.c
tree-ssa-operands.h
tree-ssa-phiopt.c
tree-ssa-phiprop.c
tree-ssa-pre.c tree-ssa-pre.c (get_representative_for): Adjust dumping. 2012-12-13 09:32:56 +00:00
tree-ssa-propagate.c
tree-ssa-propagate.h
tree-ssa-reassoc.c
tree-ssa-sccvn.c
tree-ssa-sccvn.h
tree-ssa-sink.c
tree-ssa-strlen.c
tree-ssa-structalias.c
tree-ssa-tail-merge.c
tree-ssa-ter.c
tree-ssa-threadedge.c tree-ssa-threadedge.c (propagate_threaded_block_debug_into): Avoid -Wsign-compare warning. 2012-12-13 14:28:54 +01:00
tree-ssa-threadupdate.c
tree-ssa-uncprop.c
tree-ssa-uninit.c
tree-ssa.c
tree-ssanames.c
tree-stdarg.c
tree-stdarg.h
tree-streamer-in.c
tree-streamer-out.c
tree-streamer.c re PR lto/55660 (ICE instead of some warning during lto build with supplied different options (-funsigned-char vs none)) 2012-12-13 11:13:13 +00:00
tree-streamer.h
tree-switch-conversion.c re PR lto/55736 (lto ICE: tree code ''junl is not supported in LTO streams) 2012-12-19 13:53:18 +00:00
tree-tailcall.c
tree-vect-data-refs.c
tree-vect-generic.c
tree-vect-loop-manip.c
tree-vect-loop.c re PR tree-optimization/55831 (ICE: verify_flow_info failed) 2013-01-01 00:50:00 +01:00
tree-vect-patterns.c
tree-vect-slp.c
tree-vect-stmts.c
tree-vectorizer.c
tree-vectorizer.h
tree-vrp.c
tree.c
tree.def
tree.h re PR lto/55736 (lto ICE: tree code ''junl is not supported in LTO streams) 2012-12-19 13:53:18 +00:00
treestruct.def
tsan.c
tsan.h
tsystem.h
typeclass.h
valtrack.c re PR debug/55730 (ICE in mem_loc_descriptor, at dwarf2out.c:12725) 2012-12-19 13:16:56 +01:00
valtrack.h
value-prof.c
value-prof.h
var-tracking.c re PR target/55659 ([SH] Build failure with ICE in dwarf2out_var_location, at dwarf2out.c:20748) 2012-12-12 10:56:22 +01:00
varasm.c varasm.c (bss_initializer_p): Remove static. 2012-12-21 12:25:57 -05:00
varpool.c re PR middle-end/53476 (FAIL: gcc.dg/attr-weakref-1.c) 2012-12-13 15:20:57 +00:00
vec.c
vec.h
version.c
version.h
vmsdbg.h
vmsdbgout.c
web.c
xcoff.h
xcoffout.c varasm.c (bss_initializer_p): Remove static. 2012-12-21 12:25:57 -05:00
xcoffout.h varasm.c (bss_initializer_p): Remove static. 2012-12-21 12:25:57 -05:00

Copyright (C) 2000, 2003 Free Software Foundation, Inc.

This file is intended to contain a few notes about writing C code
within GCC so that it compiles without error on the full range of
compilers GCC needs to be able to compile on.

The problem is that many ISO-standard constructs are not accepted by
either old or buggy compilers, and we keep getting bitten by them.
This knowledge until know has been sparsely spread around, so I
thought I'd collect it in one useful place.  Please add and correct
any problems as you come across them.

I'm going to start from a base of the ISO C90 standard, since that is
probably what most people code to naturally.  Obviously using
constructs introduced after that is not a good idea.

For the complete coding style conventions used in GCC, please read
http://gcc.gnu.org/codingconventions.html


String literals
---------------

Irix6 "cc -n32" and OSF4 "cc" have problems with constant string
initializers with parens around it, e.g.

const char string[] = ("A string");

This is unfortunate since this is what the GNU gettext macro N_
produces.  You need to find a different way to code it.

Some compilers like MSVC++ have fairly low limits on the maximum
length of a string literal; 509 is the lowest we've come across.  You
may need to break up a long printf statement into many smaller ones.


Empty macro arguments
---------------------

ISO C (6.8.3 in the 1990 standard) specifies the following:

If (before argument substitution) any argument consists of no
preprocessing tokens, the behavior is undefined.

This was relaxed by ISO C99, but some older compilers emit an error,
so code like

#define foo(x, y) x y
foo (bar, )

needs to be coded in some other way.


Avoid unnecessary test before free
----------------------------------

Since SunOS 4 stopped being a reasonable portability target,
(which happened around 2007) there has been no need to guard
against "free (NULL)".  Thus, any guard like the following
constitutes a redundant test:

  if (P)
    free (P);

It is better to avoid the test.[*]
Instead, simply free P, regardless of whether it is NULL.

[*] However, if your profiling exposes a test like this in a
performance-critical loop, say where P is nearly always NULL, and
the cost of calling free on a NULL pointer would be prohibitively
high, consider using __builtin_expect, e.g., like this:

  if (__builtin_expect (ptr != NULL, 0))
    free (ptr);



Trigraphs
---------

You weren't going to use them anyway, but some otherwise ISO C
compliant compilers do not accept trigraphs.


Suffixes on Integer Constants
-----------------------------

You should never use a 'l' suffix on integer constants ('L' is fine),
since it can easily be confused with the number '1'.


			Common Coding Pitfalls
			======================

errno
-----

errno might be declared as a macro.


Implicit int
------------

In C, the 'int' keyword can often be omitted from type declarations.
For instance, you can write

  unsigned variable;

as shorthand for

  unsigned int variable;

There are several places where this can cause trouble.  First, suppose
'variable' is a long; then you might think

  (unsigned) variable

would convert it to unsigned long.  It does not.  It converts to
unsigned int.  This mostly causes problems on 64-bit platforms, where
long and int are not the same size.

Second, if you write a function definition with no return type at
all:

  operate (int a, int b)
  {
    ...
  }

that function is expected to return int, *not* void.  GCC will warn
about this.

Implicit function declarations always have return type int.  So if you
correct the above definition to

  void
  operate (int a, int b)
  ...

but operate() is called above its definition, you will get an error
about a "type mismatch with previous implicit declaration".  The cure
is to prototype all functions at the top of the file, or in an
appropriate header.

Char vs unsigned char vs int
----------------------------

In C, unqualified 'char' may be either signed or unsigned; it is the
implementation's choice.  When you are processing 7-bit ASCII, it does
not matter.  But when your program must handle arbitrary binary data,
or fully 8-bit character sets, you have a problem.  The most obvious
issue is if you have a look-up table indexed by characters.

For instance, the character '\341' in ISO Latin 1 is SMALL LETTER A
WITH ACUTE ACCENT.  In the proper locale, isalpha('\341') will be
true.  But if you read '\341' from a file and store it in a plain
char, isalpha(c) may look up character 225, or it may look up
character -31.  And the ctype table has no entry at offset -31, so
your program will crash.  (If you're lucky.)

It is wise to use unsigned char everywhere you possibly can.  This
avoids all these problems.  Unfortunately, the routines in <string.h>
take plain char arguments, so you have to remember to cast them back
and forth - or avoid the use of strxxx() functions, which is probably
a good idea anyway.

Another common mistake is to use either char or unsigned char to
receive the result of getc() or related stdio functions.  They may
return EOF, which is outside the range of values representable by
char.  If you use char, some legal character value may be confused
with EOF, such as '\377' (SMALL LETTER Y WITH UMLAUT, in Latin-1).
The correct choice is int.

A more subtle version of the same mistake might look like this:

  unsigned char pushback[NPUSHBACK];
  int pbidx;
  #define unget(c) (assert(pbidx < NPUSHBACK), pushback[pbidx++] = (c))
  #define get(c) (pbidx ? pushback[--pbidx] : getchar())
  ...
  unget(EOF);

which will mysteriously turn a pushed-back EOF into a SMALL LETTER Y
WITH UMLAUT.


Other common pitfalls
---------------------

o Expecting 'plain' char to be either sign or unsigned extending.

o Shifting an item by a negative amount or by greater than or equal to
  the number of bits in a type (expecting shifts by 32 to be sensible
  has caused quite a number of bugs at least in the early days).

o Expecting ints shifted right to be sign extended.

o Modifying the same value twice within one sequence point.

o Host vs. target floating point representation, including emitting NaNs
  and Infinities in a form that the assembler handles.

o qsort being an unstable sort function (unstable in the sense that
  multiple items that sort the same may be sorted in different orders
  by different qsort functions).

o Passing incorrect types to fprintf and friends.

o Adding a function declaration for a module declared in another file to
  a .c file instead of to a .h file.