home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,664 of 33,346   
   Gennaro Prota to daniel.kruegler@googlemail.com   
   Re: Array Size : Error : Why ??   
   11 Nov 11 05:25:07   
   
   From: clcppm-poster@this.is.invalid   
      
   On Thu, 10 Nov 2011 20:09:38 +0100, Daniel Kr=FCgler  =   
      
    wrote:   
      
   > Am 09.11.2011 21:20, schrieb Vipin:   
   >> I am seeing the following as an error by compiler. I remember it   
   >> should be an error but want to know the concept behind it.   
   >   
   > To make the problem statement more clear, I deliberately simplified yo=   
   ur  =   
      
   > example to   
   >   
   > int Data[] = {0};   
   >   
   > int main (){   
   >    sizeof Data/sizeof Data[0];   
   >    sizeof (int [])(&(Data[0]))/ sizeof Data[0];   
   > }   
   >   
   > The question is: Why is the second statement in main ill-formed?   
      
         [...]   
   > Now writing a casting expression of the form   
   >   
   > (int [])(&(Data[0])   
   >   
   > is ill-formed for several reasons:   
      
   Not to talk of the fact that if you stick a sizeof in front of   
   it the parsing changes and you no longer have a cast :-)   
   Example:   
      
      int a = 0 ;   
      sizeof ( void * ) ( &a ) ; // error   
      
   -- =   
      
      Gennaro Prota         |           name.surname gmail.com   
        Breeze C++ (preview):    
        Do you need expertise in C++?   I'm available.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca