[Bug c/18740] Execution-time sizeof drops side effects
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 30 22:48:00 GMT 2004
------- Additional Comments From bangerth at dealii dot org 2004-11-30 22:48 -------
Actually, this requires more thought. I quoted from the C++ standard, but
the bug is for C, and the problem lies here: the code is
-----------------
size_t fsize3 (int n)
{
int i = 0;
char b[1][n+3]; // Variable length array.
size_t s = sizeof (b[i++]);
-----------------
Indeed, b[0] is a VLA (or is it? maybe it's the GNU extension that looks
so similar), and for that case, Morton pointed me correctly at 6.5.3.4/2 of
the C99 standard, which has a special provision for this:
If the type of the operand is a variable length array type, the
operand is evaluated; otherwise the operand is not evaluated...
Sorry for the confusion,
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18740
More information about the Gcc-bugs
mailing list