This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos 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: linking problem when using "fopen"


Jonathan Larmour wrote:
> > Using the non-throwing form of operator new might work:
> >
> >         new (std::nothrow) Cyg_StdioStream(...);
> 
> I'm afraid I doubt this will work.

I don't know about this problem here, but wouldn't "new (std::nothrow)"
be the correct solution anyway?

IIRC, gcc assumes that the standard new always succeeds if it doesn't
throw an exception (which it can't in this case due to -fno-exceptions)
and calls the constructor without checking the return value from new. So
checking for curr_stream == NULL in fopen.cxx is useless because calling
Cyg_StdioStream's constructor with a NULL this pointer will most likely
already have caused a crash.

Martin

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


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