Recently, we ran "make check" on the GCC built from the GUPC branck
and compared it against "make check" run against the GCC trunk version
of the most recent merge with the trunk.  The following failure
was detected on the GUPC branch.

cc1: internal compiler error: in print_specific_help, at opts.c:1128

The following command generates the error.

gcc/xgcc -Bgcc/ test-18810.c --help=optimizers -lm -o test-18810.x

The assertion check is here:

1126 /* Sanity check: Make sure that we do not have more
1127 languages than we have bits available to enumerate them. */
1128 gcc_assert ((1U << cl_lang_count) < CL_MIN_OPTION_CLASS);

The value of 'cl_lang_count' is calculated by an AWK script that
processes the .opt files and generates .c and .h files. The value of
CL_MIN_OPTION_CLASS is defined in opts.h.

130 #define CL_PARAMS (1U << 11) /* Fake entry. Used to display --param info 
with --help. */
131 #define CL_WARNING (1U << 12) /* Enables an (optional) warning message. */
132 #define CL_OPTIMIZATION (1U << 13) /* Enables an (optional) optimization. */
133 #define CL_DRIVER (1U << 14) /* Driver option. */
134 #define CL_TARGET (1U << 15) /* Target-specific option. */
135 #define CL_COMMON (1U << 16) /* Language-independent. */
136
137 #define CL_MIN_OPTION_CLASS CL_PARAMS
138 #define CL_MAX_OPTION_CLASS CL_COMMON

Above, we can see that CL_MIN_OPTION_CLASS is equal to CL_PARAMS,
which is a fixed value: (1U << 11).

The options.h file is generated by the AWK scripts and is present in
the 'gcc' build directory. Here's the relevant values.

    #define CL_UPC (1U << 10)
    #define CL_LANG_ALL ((1U << 11) - 1)

The cl_lang_count value is in the generated options.c file.

    const unsigned int cl_lang_count = 11;

Although I haven't reviewed the source code in detail it looks to me
like there might be two issues here:

1) The sanity check should probably read:
   gcc_assert ((1U << cl_lang_count) <= CL_MIN_OPTION_CLASS);
In other words, it is off-by-one.

2) The fixed shift counts starting at CL_PARAMS probably need to be
adjusted upwards to allow for more languages.

A third problem, is that this sort of error would be better detected
at build time rather than waiting to run a DejaGNU test to find it.
Also, the use of fixed masks is problematic.  Perhaps the AWK script
could be changed to also generate values for CL_PARAMS, etc., ensuring
that will not conflict with the language mask values?

- Gary

Reply via email to