Bug Hunting Session
Bug 53061 - Stop assuming NULL for C++ is an integral type
Summary: Stop assuming NULL for C++ is an integral type
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Stephan Bergmann
URL:
Whiteboard: target:3.7.0
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-01 22:38 UTC by Jung-uk Kim
Modified: 2012-08-16 11:01 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
A patch to fix internal CLucene (1.61 KB, patch)
2012-08-01 22:38 UTC, Jung-uk Kim
Details
A patch to fix getCppuType (53.42 KB, patch)
2012-08-01 22:40 UTC, Jung-uk Kim
Details
A patch to fix svx. (482 bytes, patch)
2012-08-14 22:58 UTC, Jung-uk Kim
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jung-uk Kim 2012-08-01 22:38:09 UTC
Now LibreOffice uses gnu++0x mode for C++ compilation if available, we should stop assuming NULL for C++ is an integral type (e.g., 0L) because some platforms rightfully define it as nullptr.  For example, recent FreeBSD defines NULL like this:

#if !defined(__cplusplus)
#define NULL    ((void *)0)
#else
#if __cplusplus >= 201103L
#define NULL    nullptr
#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
#define NULL    __null
#else
#if defined(__LP64__)
#define NULL    (0L)
#else
#define NULL    0
#endif  /* __LP64__ */
#endif  /* __GNUG__ */
#endif  /* !__cplusplus */

With GCC 4.7+ (and Clang 3.2+), __cplusplus is correctly defined as 201103L and it is causing lots of build issues with these new C++ compilers.
Comment 1 Jung-uk Kim 2012-08-01 22:38:47 UTC
Created attachment 65048 [details]
A patch to fix internal CLucene
Comment 2 Jung-uk Kim 2012-08-01 22:40:41 UTC
Created attachment 65049 [details]
A patch to fix getCppuType
Comment 3 Jung-uk Kim 2012-08-01 22:43:21 UTC
There may be more of these but I found these two major problems so far.
Comment 4 Stephan Bergmann 2012-08-10 16:23:42 UTC
Jung-uk Kim, thank you for those patches.  They do look good (I just wonder whether the "return (vt_)NULL;" in CLucene is really necessary, or could rather be simplified to "return NULL;"), but we would need a statement from you to the mailing list (libreoffice@lists.freedesktop.org) stating which license they are under (preferably MPL/LGPLv3+ dual licensed), and adding that to <http://wiki.documentfoundation.org/Development/Developers>.
Comment 5 Jung-uk Kim 2012-08-10 16:55:43 UTC
(In reply to comment #4)
> Jung-uk Kim, thank you for those patches.  They do look good (I just wonder
> whether the "return (vt_)NULL;" in CLucene is really necessary, or could rather
> be simplified to "return NULL;"), but we would need a statement from you to the
> mailing list (libreoffice@lists.freedesktop.org) stating which license they are
> under (preferably MPL/LGPLv3+ dual licensed), and adding that to
> <http://wiki.documentfoundation.org/Development/Developers>.

CLucene patch is necessary, at least for Clang:

/home/jkim/clucene-core-2.3.3.4/src/core/CLucene/util/VoidMap.h:86:11: error: 
      cannot initialize return object of type
      'lucene::document::DateTools::Resolution' with an rvalue of type
      'nullptr_t'
                        return NULL;
                               ^~~~

I'm fine with MPL/LGPLv3+ dual-licensing.  BTW, is it necessary to send a separate e-mail?  I mean Bugzilla won't disappear and it's automatically forwarded to the ML, right?  If it is really needed, it will be done.  Thanks!
Comment 6 Not Assigned 2012-08-14 08:44:19 UTC
Jung-uk Kim committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e19cd3f8a39fdb9878cb573438e04ae325405ffe

fdo#53061: Fix for C++11 #define NULL nullptr
Comment 7 Not Assigned 2012-08-14 08:44:44 UTC
Jung-uk Kim committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ed93117447a3217fab0e2425f8761e24423024b5

fdo#53061: Fix for C++11 #define NULL nullptr
Comment 8 Stephan Bergmann 2012-08-14 09:12:14 UTC
(In reply to comment #5)
> CLucene patch is necessary, at least for Clang:
> 
> /home/jkim/clucene-core-2.3.3.4/src/core/CLucene/util/VoidMap.h:86:11: error: 
>       cannot initialize return object of type
>       'lucene::document::DateTools::Resolution' with an rvalue of type
>       'nullptr_t'
>                         return NULL;
>                                ^~~~

ah right, Resolution is an enum there

> I'm fine with MPL/LGPLv3+ dual-licensing.  BTW, is it necessary to send a
> separate e-mail?  I mean Bugzilla won't disappear and it's automatically
> forwarded to the ML, right?  If it is really needed, it will be done.  Thanks!

Probably enough to have it recorded here in this issue.  I added you to the roster as <https://wiki.documentfoundation.org/index.php?title=Development/Developers&oldid=54368>.

The two patches are applied now, see comment 6 and comment 7.  Thanks again.

Did you file the CLucene patch also upstream at CLucene itself?
Comment 9 Jung-uk Kim 2012-08-14 15:32:33 UTC
(In reply to comment #8)
> The two patches are applied now, see comment 6 and comment 7.  Thanks again.

Great, thanks!

> Did you file the CLucene patch also upstream at CLucene itself?

No, I didn't feel it's necessary because it looks like the project does not have an active maintainer any more.  The last commit was more than a year ago although there were several patch submissions after the release. :-(

http://clucene.git.sourceforge.net/git/gitweb.cgi?p=clucene/clucene;a=summary
http://sourceforge.net/tracker/?group_id=80013&atid=558446
http://sourceforge.net/mailarchive/forum.php?forum_name=clucene-developers
Comment 10 Jung-uk Kim 2012-08-14 22:58:04 UTC
Created attachment 65571 [details]
A patch to fix svx.

I found one more file to fix.
Comment 11 Not Assigned 2012-08-16 11:01:03 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e413403590c3fb68a62db6d34d202e320fd99017

fdo#53061: Work around boost::ptr_vector.insert(..., nullptr) problem