Article View: gnu.gcc.help
Article #963Re: casting operator
From: Kim Seungtai
Date: Sat, 01 Mar 2003 19:14
Date: Sat, 01 Mar 2003 19:14
14 lines
1845 bytes
1845 bytes
"Maya" > size_t num = 3; > std::cout << reinterpret_cast<char*> (num) << std::endl; > Can someone please tell me if there is a problem with the code above, it > keeps giving me a segmentation fault! Although a value of integral type can be reinterpreted to a pointer, the result might not be a valid pointer. It's depend on your implementation. Only It's guaranteed converting between a integer and a pointer that a pointer converted to an integer and the integer back to same type's pointer and the integer is zero which yields a null pointer. S Kim
Technical Details
Message-ID:
<b3r10j$9b7$1@news.kreonet.re.kr>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.kreonet.re.kr!news.kreonet.re.kr!not-for-mailReferences:
<pan.2003.03.01.11.18.50.909884.1065@canada.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,b715bb86231f2439 X-Google-Attributes: gid11318c,public X-Google-Thread: fa69e,b715bb86231f2439 X-Google-Attributes: gidfa69e,public X-Google-Thread: 114592,b715bb86231f2439 X-Google-Attributes: gid114592,public X-Google-ArrivalTime: 2003-03-01 11:15:40 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.kreonet.re.kr!news.kreonet.re.kr!not-for-mail From: "Kim, Seungtai" <stkim@Heartmore. Com> Newsgroups: gnu.gcc.help,borland.public.cpp.borlandcpp,alt.comp.lang.learn.c-c++ Subject: Re: casting operator Date: Sun, 2 Mar 2003 04:14:12 +0900 Organization: Korea Research Environment Open Network Lines: 16 Message-ID: <b3r10j$9b7$1@news.kreonet.re.kr> References: <pan.2003.03.01.11.18.50.909884.1065@canada.com> NNTP-Posting-Host: 211.212.62.71 X-Trace: news.kreonet.re.kr 1046546259 9575 211.212.62.71 (1 Mar 2003 19:17:39 GMT) X-Complaints-To: usenet@news.kreonet.re.kr NNTP-Posting-Date: Sat, 1 Mar 2003 19:17:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106