This is the mail archive of the gcc-bugs@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]

[Bug c/18740] Execution-time sizeof drops side effects


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]