Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5379

Re: Is this valid code or UB?

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Is this valid code or UB?
Date 2011-05-24 11:15 +1200
Message-ID <94084lFt2pU16@mid.individual.net> (permalink)
References <UKACp.14009$UY3.5807@newsfe20.ams2>

Show all headers | View raw


On 05/24/11 09:57 AM, Paul wrote:
> Yes I'm still arguing about arrays. Anyway consider the following:
>
> int main(){
>   int (*p)[3]=0;
>   std::cout<<*p<<std::endl;
>   std::cout<<  typeid(*p).name()<<std::endl;
>   std::cout<<  sizeof(*p);
> }
>
> Does a valid array type object exist?

No.

> Is it UB because it dereferences a null pointer?

Yes.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is this valid code or UB? "Paul" <pchristor@yahoo.co.uk> - 2011-05-23 22:57 +0100
  Re: Is this valid code or UB? Leigh Johnston <leigh@i42.co.uk> - 2011-05-23 23:05 +0100
  Re: Is this valid code or UB? Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2011-05-23 16:04 -0700
  Re: Is this valid code or UB? Ian Collins <ian-news@hotmail.com> - 2011-05-24 11:15 +1200
  Re: Is this valid code or UB? Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-23 16:35 -0700
    Re: Is this valid code or UB? "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-24 02:38 +0200
      Re: Is this valid code or UB? Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-23 18:36 -0700

csiph-web