Re: std::cout breaks after nullptr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-03-25 12:11 +0100, Marc Glisse wrote:
> On Mon, 25 Mar 2019, Jonathan Wakely wrote:
> > On Sun, 24 Mar 2019, 13:53 Xi Ruoyao, <xry111@xxxxxxxxxxxxxxxx> wrote:
> > > Well, if you want this to be detected at compile time, maybe you can
> > > convince
> > > Jonathan to add an __attribute__((nonnull(2))) to
> > > operator<<(basic_ostream&,
> > > const char *).  Then this case can be detected with "-O -Wnonnull".
> > 
> > That seems like a good idea.
> 
> Note that IIRC the attribute is also used for optimization purposes. 
> Adding it would remove the test "if (!__s)". One could try and add the 
> attribute only for user code and not while compiling the library itself, 
> but that's getting complicated (_GLIBCXX_EXTERN_TEMPLATE, specializations 
> for types other than char, etc).

Oh really.  I'd been misunderstanding "nonnull" as a pure diagnostic attribute
for long time :(.
-- 
Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux