This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18740] Execution-time sizeof drops side effects
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Nov 2004 22:48:23 -0000
- Subject: [Bug c/18740] Execution-time sizeof drops side effects
- References: <20041130163828.18740.terra@gnome.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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