[HarfBuzz] Questionable use of DEBUG
Konstantin Ritt
ritt.ks at gmail.com
Mon Apr 29 23:41:30 PDT 2013
Hi Behdad,
John is probably right, having DEBUG macro defined in release mode could
potentially lead to a hard-tracking issues. And this possibility grows when
we're compiling Harfbuzz in instead of linking to it.
Maybe worth of renaming to HB_DEBUG?
Kind regards,
Konstantin
2013/4/30 John Emmas <johne53 at tiscali.co.uk>
> On 29/04/2013 10:15, John Emmas wrote:
>
>>
>> On 27/04/2013 21:37, Behdad Esfahbod wrote:
>>
>>>
>>> The debug is fine. The if gets optimized out by the compiler. That's by
>>> design.
>>>
>>>
>> Hi Behdad. Can I ask how confident you are about this (for example, is
>> there something in the Harfbuzz code to guarantee that there won't be a
>> DEBUG macro when we're building our Release code?)
>>
>>
>>
> FWIW I took a more detailed look into this and I now have a better
> understanding of what you meant by "optimized out". AFAICT any Harfbuzz
> statements that look something like this:-
>
> if (DEBUG (BUFFER))
>
> will effectively evaluate to this:-
>
> if (0)
>
> so yes, the compiler will (hopefully) optimize them away when building
> optimized code - but actually, that's not what I was worried about. I was
> worrying about whether your custom DEBUG macro could ever get exposed to
> the outside world. Let's say that one of the Harfbuzz public header files
> could eventually include that DEBUG macro. If some unsuspecting programmer
> #included the public header, he could unwittingly have DEBUG defined
> without realizing it. When interacting with other libraries, this could
> lead to some very subtle bugs which could be extremely difficult to track
> down.
>
> The good news though is that after taking a more detailed look at
> Harfbuzz, I can't find any path where that could happen so (for now at
> least) the outside world is safe and I feel a lot more reassured! ;-)
>
> I just wanted to record it here, in case I need to remind myself in the
> future!
>
> But if I'd written that macro I think I'd have been tempted to play safe
> and call it something else.... ;-)
>
>
> John
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20130430/9ac49a08/attachment.html>
More information about the HarfBuzz
mailing list