This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wow..


On 3 February 2015 at 00:03, mr.X wrote:
> Hello GCC team!
>
>   First of all, excuse me for bad english.
>   So, why can't I do this (real code parts):
>
>   ----------------------------- g++ --std=c++14
>
>   unsigned long long a = 0;
>   shared_ptr< char* > c = make_shared<>()

This is not valid code, I assume you mean make_shared<char*>()

That creates a char* and initializes it as a null pointer, so *c == nullptr.

>
>   void f( ull* P )
>   {
>      if( *P == a )          -- seg fault here. if i comment it..
>      if( *c != nullptr )    -- seg fault here then.
>                cout << "It's ok!\n"; -- never printed!
>   }
>
>   f( &a );
>
>   ----------------------------- g++ --std=c++14

Please post a complete working example showing the problem, not
incomplete pieces of code that cannot be compiled. That means you must
show the code including all headers, 'using namespace std' etc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]