1 From b79d478c21ed6af20554ead97da72de845dc3206 Mon Sep 17 00:00:00 2001
2 From: Peter Korsgaard <peter@korsgaard.com>
3 Date: Sat, 25 Feb 2017 21:57:19 +0100
4 Subject: [PATCH] Fix build with gcc 6
6 Gcc 6.x defaults to C++14, and the iostream operator bool behaviour changed
7 in C++11. In previous versions, a somewhat odd operator void* was used to
8 return the status of the stream as a pointer. Since C++11 a more sensible
9 operator bool is used to return the stream staus.
13 http://en.cppreference.com/w/cpp/io/basic_ios/operator_bool
15 The code in CConfigReadContext assumes the pre-C++11 behaviour and provides
16 its own operator void overload to return the status of the embedded
17 iostream. With C++11, iostream no longer provides this overload, breaking
20 CConfig.cpp: In member function 'CConfigReadContext::operator void*() const':
21 CConfig.cpp:1851:9: error: cannot convert 'std::istream {aka std::basic_istream<char>}' to 'void*' in return
24 To fix it, backport part of upstream commit 3d963bfbe7897d0a33ad (possible
25 fix for mavericks) which changes the code to simply provide a getStream()
26 method which returns a reference to the embedded stream and the calling code
27 is changed to use operator bool on the returned stream, making the code
28 compatible with both old and new compilers.
30 This upstream commit is part of the 1.6.0 release, so can be dropped when
31 the version is bumped.
33 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
35 lib/server/CConfig.cpp | 7 +------
36 lib/server/CConfig.h | 2 +-
37 2 files changed, 2 insertions(+), 7 deletions(-)
39 diff --git a/lib/server/CConfig.cpp b/lib/server/CConfig.cpp
40 index a502fe78..d67dde20 100644
41 --- a/lib/server/CConfig.cpp
42 +++ b/lib/server/CConfig.cpp
43 @@ -607,7 +607,7 @@ void
44 CConfig::read(CConfigReadContext& context)
48 + while (context.getStream()) {
49 tmp.readSection(context);
52 @@ -1846,11 +1846,6 @@ CConfigReadContext::getLineNumber() const
56 -CConfigReadContext::operator void*() const
62 CConfigReadContext::operator!() const
64 diff --git a/lib/server/CConfig.h b/lib/server/CConfig.h
65 index c0d2faa8..0ee453cb 100644
66 --- a/lib/server/CConfig.h
67 +++ b/lib/server/CConfig.h
68 @@ -480,7 +480,6 @@ public:
69 bool readLine(CString&);
70 UInt32 getLineNumber() const;
72 - operator void*() const;
73 bool operator!() const;
75 OptionValue parseBoolean(const CString&) const;
76 @@ -502,6 +501,7 @@ public:
77 IPlatformScreen::CButtonInfo*
78 parseMouse(const CString& mouse) const;
79 KeyModifierMask parseModifier(const CString& modifiers) const;
80 + std::istream& getStream() const { return m_stream; };