This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
The following patch is another TREE_OVERFLOW related clean-up. A patch
I've been experimenting with to track overflow more precisely on sizetypes
has revealed a latent bug in the g++ front-end's error handling routines.
The code that calculates the size of an array to report in a diagnostic
message is incorrectly/inappropriately using the front-end's high-level
binary operator APIs. These APIs are useful to the front-end to perform
appropriate implicit conversions, and to report type conflicts and
overflowing operations. Unfortunately, encountering such an error whilst
processing an error causes GCC's diagnostic machinery to ICE, with an
assertion about recursion during error processing.
The actual source of the error in the few testsuite test cases that I
examined were legitimately caused by the C++'s representation of zero
sized arrays. Internally, a field of type x[0] in g++ has an unsigned
sizetype index-type with a TYPE_MAX_VALUE of UINT_MAX. When we add one to
this "sizetype" we should get an overflow, and using the
cp_build_binary_op interface we get the recursive diagnostic and thus ICE.
The bug is currently latent becuase we don't correctly detect this
overflow, and instead report the array as "x[O]". The patch below allows
us to preserve this current behaviour, by using the lower-level
fold-const.c APIs to perform the addition, which won't attempt to issue a
warning even if it decides to set TREE_OVERFLOW.
The following patch has been tested on i686-pc-linux-gnu, with a full
"make boostrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.
Ok for mainline?
2007-01-30 Roger Sayle <roger@eyesopen.com>
* error.c (dump_type_suffix): Avoid use of cp_build_binary_op when
calculating the size of an array (to avoid recursive errors).
Roger
--
Attachment:
patchs6.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |