GNOME Bugzilla – Bug 145294
Boolean expression as template argument confuses doxygen
Last modified: 2013-05-19 12:36:32 UTC
Try running doxygen on the following C++ file: ------------------------------------------------------------------ /** Test Class 1. */ template <class _Host, bool _RealLock> class_level_lock { public: /** Lock. */ void lock(); /** Unlock. */ void unlock(); }; /** Test Class 2. */ template <int _ClientId> class Client : public class_level_lock<Client, (_ClientId < 0)> { public: /** A test member function. */ void test(); }; ------------------------------------------------------------------ No class documentation will be generated at all. Changing "(_ClientId < 0)" to something like "true" will make something appear, but still not quite right. Something non-existent like "Client<Client, true>" appears in the inheritance diagram. Not only inheritance, but also just using "class_level_lock<Client, (_ClientId < 0)>" will cause miscellaneous problems.
This is a known issue. At several places in the code it is assumed that in the argument list of a template the number of <'s and >'s matches. I've tried to fixed this before, but it is not easy at all. As a workaround you could use: ------------------------------------------------------------------------------ /** Test Class 1. */ template <template<int> class _Host, bool _RealLock> class class_level_lock { public: /** Lock. */ void lock(); /** Unlock. */ void unlock(); }; #define IS_REAL_LOCK(id) (id<0) /** Test Class 2. */ template <int _ClientId> class Client : public class_level_lock<Client, IS_REAL_LOCK(_ClientId)> { public: /** A test member function. */ void test(); }; ------------------------------------------------------------------------------ Note that I also had to adjust the first template argument of the lock before my compiler (gcc 3.3) would accept it as valid C++!
Sorry that I did not make it right when adapting the test case. In fact, apart from the omission of keywork `class' on l. 3, l. 13 is intended to be class Client : public class_level_lock<Client<_ClientId>, (_ClientId < 0)> { My fault not having tested it.
This bug was resolved to status "FIXED" as part of a group change. Please verify that this bug is indeed fixed in doxygen version 1.4.5 (or later). If not then please reopen the bug, so it stays on my radar.
Really fixed in 1.4.5? My test with doxygen-1.4.5.windows.bin.zip did not show so. I use the same old test file: /** * @file test.cpp */ /** Test Class 1. */ template <class _Host, bool _RealLock> class class_level_lock { public: /** Lock. */ void lock(); /** Unlock. */ void unlock(); }; /** Test Class 2. */ template <int _ClientId> class Client : public class_level_lock<Client<_ClientId>, (_ClientId < 0)> { public: /** A test member function. */ void test(); }; No diagrams are output, until I change "(_ClientId < 0)" to something like "(_ClientId != 0)" or "true", i.e., remove the less-than or greater-than character.
I assumed it was fixed since the status was "assigned". You are right that it is not. I have a fix now, so it should appear in the next CVS update.
This bug had the status ASSIGNED (which meant it was fixed, but not officially released), so now doxygen release 1.4.6 is out I've given it the status FIXED. Nevertheless, I would like to ask you to verify that this bug is indeed fixed in release 1.4.6. If not, then please reopen the bug.
Hi Dimitri, I just tested it and regretted to inform you that the bug is still there. Since I changed job, I cannot access my old e-mail address and it seems I cannot change the status of the bug now.
Reopen, as per request of the submitter.
Please find attached a simple test showing what seems to be a variant of the bug described here above. The test uses several Boolean operators in expressions occurring in template parameter lists (which is often the case when using template meta-programming techniques): besides the case of relational operators < and > being (mis-) interpreted as unbalanced angled parentheses, it shows a problem with the use of balanced (round, i.e., not angled) parentheses.
Created attachment 92720 [details] other variations for what seems to be the same bug
I've tested the problem from Wu Yongwei with version 1.4.5 and with version 1.8.3.1 and with version 1.4.5 I don't see any graphs in "Client< _ClientId > Class Template Reference" whilst these are present in version 1.8.3.1 In respect to the problem as mentioned by zaffanella, the ko2 variable still does not show up, so this bug is still present, I don't see any error message regarding it though.
Confirmed. The problem with ko2 should be fixed in the next subversion update.
This bug was previously marked ASSIGNED, which means it should be fixed in doxygen version 1.8.4. Please verify if this is indeed the case. Reopen the bug if you think it is not fixed and please include any additional information that you think can be relevant.