[Bug c++/61125] New: static_cast of null pointer return invalid pointer (not null)

2014-05-09 Thread slorents at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61125

Bug ID: 61125
   Summary: static_cast of null pointer return invalid pointer
(not null)
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: slorents at gmail dot com

Created attachment 32766
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32766&action=edit
Bug example

The standard indicates that if a null pointer value is being cast that the
result will be a null pointer value (5.2.9/8 Static cast).

See attachment.

gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 64 bit

Output:
hook = 7fffe504obj = 7fffe500 right=7fffe500
hook =  obj = fffc right=


MyObj *obj = static_cast(hook)

Expected  instead fffc.


[Bug c++/61125] static_cast of null pointer return invalid pointer (not null)

2014-05-09 Thread slorents at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61125

Stanislav Lorents  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Stanislav Lorents  ---
It is undefined behavior to call a member function through a null pointer.
Inside class member function 'this' pointer must be not null.