freetype-devel
[Top][All Lists]
Advanced

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

Microsoft compiler bug


From: Derek B. Noonburg
Subject: Microsoft compiler bug
Date: Wed, 29 Sep 2021 11:26:37 -0700

I ran into what appears to be a Microsoft compiler bug, triggered by a
change in the FreeType 2.11.0 release.

autofit/afwrtsys.h looks like this:

#ifndef AFWRTSYS_H_
#define AFWRTSYS_H_
... some stuff ...
#endif /* AFWRTSYS_H_ */
... more stuff, but only preprocessor macro output ...

The first time this file is included in afglobal.c, the "more stuff"
section is empty, and the Microsoft compiler (I suspect) marks the
header as guarded by AFWRTSYS_H_.  The second include is skipped,
because the compiler incorrectly believes there's no unguarded content
in the file.  The end result is that the af_writing_system_classes
array is empty, which leads to a crash.

My workaround is to add:

#ifdef NONEXISTENT_SYMBOL
#endif

at the very end of afwrtsys.h.  That appears to be enough to get the
compiler to reload the header on the second include.

This only popped up in 2.11.0 because 2.10.4 just happened to have an
#ifdef in the "more stuff" section.  I haven't looked at older releases.

I've reproduced this with Visual Studio 2017 and 2019.  Here's my bug
report to MS:

https://developercommunity2.visualstudio.com/t/include-files-with-partial-include-guard/1541705

I'd be curious to know if anyone else has encountered this.

- Derek



reply via email to

[Prev in Thread] Current Thread [Next in Thread]