🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Maya Sat, 01 Mar 2003 16:18
casting operator
#962
Author: Maya
Date: Sat, 01 Mar 2003 16:18
14 lines
2283 bytes
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!

Thank in advance.
-- 
====================== E-Communications Canada =====================
Jorge Escalante - Software Development Coordinator.
E-Mail Policy http://www.vif.com/users/escalante/Email_Policy.html

* You cannot exercise your power to a point of humiliation of others.
* What does an elephant do when he gets a broken toe?
          -He calls a toetruck
Re: casting operator
#963
Author: Kim Seungtai
Date: Sat, 01 Mar 2003 19:14
14 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads