Bug 122605 - New GCC 9 warning (-Wdeprecated-copy)
Summary: New GCC 9 warning (-Wdeprecated-copy)
Status: RESOLVED FIXED
Alias: None
Product: cppunit
Classification: Unclassified
Component: General (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Martin Liška
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-09 15:34 UTC by Martin Liška
Modified: 2019-08-06 14:31 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-01-09 15:34:46 UTC
Using latest GCC 9 one can see (with default -Wdeprecated-copy):

[  113s] In file included from ../../include/cppunit/TestCase.h:6,
[  113s]                  from ../../include/cppunit/TestCaller.h:5,
[  113s]                  from ../../include/cppunit/extensions/HelperMacros.h:9,
[  113s]                  from OrthodoxTest.h:4,
[  113s]                  from OrthodoxTest.cpp:2:
[  113s] ../../include/cppunit/extensions/Orthodox.h: In instantiation of 'void CppUnit::Orthodox<ClassUnderTest>::runTest() [with ClassUnderTest = OrthodoxTest::ValueBadAssignment]':
[  113s] ../../include/cppunit/extensions/Orthodox.h:56:38:   required from here
[  113s] ../../include/cppunit/extensions/Orthodox.h:77:23: error: implicitly-declared 'constexpr OrthodoxTest::ValueBadAssignment::ValueBadAssignment(const OrthodoxTest::ValueBadAssignment&)' is deprecated [-Werror=deprecated-copy]
[  113s]    77 |     CPPUNIT_ASSERT (c == call (a));
[  113s] ../../include/cppunit/TestAssert.h:240:37: note: in definition of macro 'CPPUNIT_ASSERT'
[  113s]   240 |   ( CPPUNIT_NS::Asserter::failIf( !(condition),                                   \
[  113s]       |                                     ^~~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:2:
[  113s] OrthodoxTest.h:159:25: note: because 'OrthodoxTest::ValueBadAssignment' has user-provided 'OrthodoxTest::ValueBadAssignment& OrthodoxTest::ValueBadAssignment::operator=(const OrthodoxTest::ValueBadAssignment&)'
[  113s]   159 |     ValueBadAssignment &operator =( const ValueBadAssignment & )
[  113s]       |                         ^~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:3:
[  113s] ../../include/cppunit/extensions/Orthodox.h:87:63: note:   initializing argument 1 of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::ValueBadAssignment]'
[  113s]    87 | ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
[  113s]       |                                                ~~~~~~~~~~~~~~~^~~~~~
[  113s] In file included from ../../include/cppunit/TestCase.h:6,
[  113s]                  from ../../include/cppunit/TestCaller.h:5,
[  113s]                  from ../../include/cppunit/extensions/HelperMacros.h:9,
[  113s]                  from OrthodoxTest.h:4,
[  113s]                  from OrthodoxTest.cpp:2:
[  113s] ../../include/cppunit/extensions/Orthodox.h:80:23: error: implicitly-declared 'constexpr OrthodoxTest::ValueBadAssignment::ValueBadAssignment(const OrthodoxTest::ValueBadAssignment&)' is deprecated [-Werror=deprecated-copy]
[  113s]    80 |     CPPUNIT_ASSERT (c == call (b));
[  113s] ../../include/cppunit/TestAssert.h:240:37: note: in definition of macro 'CPPUNIT_ASSERT'
[  113s]   240 |   ( CPPUNIT_NS::Asserter::failIf( !(condition),                                   \
[  113s]       |                                     ^~~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:2:
[  113s] OrthodoxTest.h:159:25: note: because 'OrthodoxTest::ValueBadAssignment' has user-provided 'OrthodoxTest::ValueBadAssignment& OrthodoxTest::ValueBadAssignment::operator=(const OrthodoxTest::ValueBadAssignment&)'
[  113s]   159 |     ValueBadAssignment &operator =( const ValueBadAssignment & )
[  113s]       |                         ^~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:3:
[  113s] ../../include/cppunit/extensions/Orthodox.h:87:63: note:   initializing argument 1 of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::ValueBadAssignment]'
[  113s]    87 | ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
[  113s]       |                                                ~~~~~~~~~~~~~~~^~~~~~
[  113s] ../../include/cppunit/extensions/Orthodox.h: In instantiation of 'void CppUnit::Orthodox<ClassUnderTest>::runTest() [with ClassUnderTest = OrthodoxTest::ValueBadCall]':
[  113s] ../../include/cppunit/extensions/Orthodox.h:56:38:   required from here
[  113s] ../../include/cppunit/extensions/Orthodox.h:65:5: error: implicitly-declared 'OrthodoxTest::ValueBadCall& OrthodoxTest::ValueBadCall::operator=(const OrthodoxTest::ValueBadCall&)' is deprecated [-Werror=deprecated-copy]
[  113s]    65 |     b.operator= (a.operator! ());
[  113s]       |     ^
[  113s] In file included from OrthodoxTest.cpp:2:
[  113s] OrthodoxTest.h:136:5: note: because 'OrthodoxTest::ValueBadCall' has user-provided 'OrthodoxTest::ValueBadCall::ValueBadCall(const OrthodoxTest::ValueBadCall&)'
[  113s]   136 |     ValueBadCall( const ValueBadCall & ) : Value()
[  113s]       |     ^~~~~~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:3:
[  113s] ../../include/cppunit/extensions/Orthodox.h:69:7: error: implicitly-declared 'OrthodoxTest::ValueBadCall& OrthodoxTest::ValueBadCall::operator=(const OrthodoxTest::ValueBadCall&)' is deprecated [-Werror=deprecated-copy]
[  113s]    69 |     b = !!a;
[  113s]       |     ~~^~~~~
[  113s] In file included from OrthodoxTest.cpp:2:
[  113s] OrthodoxTest.h:136:5: note: because 'OrthodoxTest::ValueBadCall' has user-provided 'OrthodoxTest::ValueBadCall::ValueBadCall(const OrthodoxTest::ValueBadCall&)'
[  113s]   136 |     ValueBadCall( const ValueBadCall & ) : Value()
[  113s]       |     ^~~~~~~~~~~~
[  113s] In file included from OrthodoxTest.cpp:3:
[  113s] ../../include/cppunit/extensions/Orthodox.h:73:7: error: implicitly-declared 'OrthodoxTest::ValueBadCall& OrthodoxTest::ValueBadCall::operator=(const OrthodoxTest::ValueBadCall&)' is deprecated [-Werror=deprecated-copy]
[  113s]    73 |     b = !a;
[  113s]       |     ~~^~~~
[  113s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:136:5: note: because 'OrthodoxTest::ValueBadCall' has user-provided 'OrthodoxTest::ValueBadCall::ValueBadCall(const OrthodoxTest::ValueBadCall&)'
[  114s]   136 |     ValueBadCall( const ValueBadCall & ) : Value()
[  114s]       |     ^~~~~~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:3:
[  114s] ../../include/cppunit/extensions/Orthodox.h:76:7: error: implicitly-declared 'OrthodoxTest::ValueBadCall& OrthodoxTest::ValueBadCall::operator=(const OrthodoxTest::ValueBadCall&)' is deprecated [-Werror=deprecated-copy]
[  114s]    76 |     c = a;
[  114s]       |     ~~^~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:136:5: note: because 'OrthodoxTest::ValueBadCall' has user-provided 'OrthodoxTest::ValueBadCall::ValueBadCall(const OrthodoxTest::ValueBadCall&)'
[  114s]   136 |     ValueBadCall( const ValueBadCall & ) : Value()
[  114s]       |     ^~~~~~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:3:
[  114s] ../../include/cppunit/extensions/Orthodox.h:79:7: error: implicitly-declared 'OrthodoxTest::ValueBadCall& OrthodoxTest::ValueBadCall::operator=(const OrthodoxTest::ValueBadCall&)' is deprecated [-Werror=deprecated-copy]
[  114s]    79 |     c = b;
[  114s]       |     ~~^~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:136:5: note: because 'OrthodoxTest::ValueBadCall' has user-provided 'OrthodoxTest::ValueBadCall::ValueBadCall(const OrthodoxTest::ValueBadCall&)'
[  114s]   136 |     ValueBadCall( const ValueBadCall & ) : Value()
[  114s]       |     ^~~~~~~~~~~~
[  114s] In file included from ../../include/cppunit/TestCase.h:6,
[  114s]                  from ../../include/cppunit/TestCaller.h:5,
[  114s]                  from ../../include/cppunit/extensions/HelperMacros.h:9,
[  114s]                  from OrthodoxTest.h:4,
[  114s]                  from OrthodoxTest.cpp:2:
[  114s] ../../include/cppunit/extensions/Orthodox.h: In instantiation of 'void CppUnit::Orthodox<ClassUnderTest>::runTest() [with ClassUnderTest = OrthodoxTest::Value]':
[  114s] ../../include/cppunit/extensions/Orthodox.h:56:38:   required from here
[  114s] ../../include/cppunit/extensions/Orthodox.h:77:23: error: implicitly-declared 'constexpr OrthodoxTest::Value::Value(const OrthodoxTest::Value&)' is deprecated [-Werror=deprecated-copy]
[  114s]    77 |     CPPUNIT_ASSERT (c == call (a));
[  114s] ../../include/cppunit/TestAssert.h:240:37: note: in definition of macro 'CPPUNIT_ASSERT'
[  114s]   240 |   ( CPPUNIT_NS::Asserter::failIf( !(condition),                                   \
[  114s]       |                                     ^~~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:41:12: note: because 'OrthodoxTest::Value' has user-provided 'OrthodoxTest::Value& OrthodoxTest::Value::operator=(const OrthodoxTest::Value&)'
[  114s]    41 |     Value& operator= ( const Value& v )
[  114s]       |            ^~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:3:
[  114s] ../../include/cppunit/extensions/Orthodox.h:87:63: note:   initializing argument 1 of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::Value]'
[  114s]    87 | ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
[  114s]       |                                                ~~~~~~~~~~~~~~~^~~~~~
[  114s] In file included from ../../include/cppunit/TestCase.h:6,
[  114s]                  from ../../include/cppunit/TestCaller.h:5,
[  114s]                  from ../../include/cppunit/extensions/HelperMacros.h:9,
[  114s]                  from OrthodoxTest.h:4,
[  114s]                  from OrthodoxTest.cpp:2:
[  114s] ../../include/cppunit/extensions/Orthodox.h:80:23: error: implicitly-declared 'constexpr OrthodoxTest::Value::Value(const OrthodoxTest::Value&)' is deprecated [-Werror=deprecated-copy]
[  114s]    80 |     CPPUNIT_ASSERT (c == call (b));
[  114s] ../../include/cppunit/TestAssert.h:240:37: note: in definition of macro 'CPPUNIT_ASSERT'
[  114s]   240 |   ( CPPUNIT_NS::Asserter::failIf( !(condition),                                   \
[  114s]       |                                     ^~~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:41:12: note: because 'OrthodoxTest::Value' has user-provided 'OrthodoxTest::Value& OrthodoxTest::Value::operator=(const OrthodoxTest::Value&)'
[  114s]    41 |     Value& operator= ( const Value& v )
[  114s]       |            ^~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:3:
[  114s] ../../include/cppunit/extensions/Orthodox.h:87:63: note:   initializing argument 1 of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::Value]'
[  114s]    87 | ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
[  114s]       |                                                ~~~~~~~~~~~~~~~^~~~~~
[  114s] ../../include/cppunit/extensions/Orthodox.h: In instantiation of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::ValueBadAssignment]':
[  114s] ../../include/cppunit/extensions/Orthodox.h:77:5:   required from 'void CppUnit::Orthodox<ClassUnderTest>::runTest() [with ClassUnderTest = OrthodoxTest::ValueBadAssignment]'
[  114s] ../../include/cppunit/extensions/Orthodox.h:56:38:   required from here
[  114s] ../../include/cppunit/extensions/Orthodox.h:89:12: error: implicitly-declared 'constexpr OrthodoxTest::ValueBadAssignment::ValueBadAssignment(const OrthodoxTest::ValueBadAssignment&)' is deprecated [-Werror=deprecated-copy]
[  114s]    89 |     return object;
[  114s]       |            ^~~~~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:159:25: note: because 'OrthodoxTest::ValueBadAssignment' has user-provided 'OrthodoxTest::ValueBadAssignment& OrthodoxTest::ValueBadAssignment::operator=(const OrthodoxTest::ValueBadAssignment&)'
[  114s]   159 |     ValueBadAssignment &operator =( const ValueBadAssignment & )
[  114s]       |                         ^~~~~~~~
[  114s] In file included from OrthodoxTest.cpp:3:
[  114s] ../../include/cppunit/extensions/Orthodox.h: In instantiation of 'ClassUnderTest CppUnit::Orthodox<ClassUnderTest>::call(ClassUnderTest) [with ClassUnderTest = OrthodoxTest::Value]':
[  114s] ../../include/cppunit/extensions/Orthodox.h:77:5:   required from 'void CppUnit::Orthodox<ClassUnderTest>::runTest() [with ClassUnderTest = OrthodoxTest::Value]'
[  114s] ../../include/cppunit/extensions/Orthodox.h:56:38:   required from here
[  114s] ../../include/cppunit/extensions/Orthodox.h:89:12: error: implicitly-declared 'constexpr OrthodoxTest::Value::Value(const OrthodoxTest::Value&)' is deprecated [-Werror=deprecated-copy]
[  114s]    89 |     return object;
[  114s]       |            ^~~~~~
[  114s] In file included from OrthodoxTest.cpp:2:
[  114s] OrthodoxTest.h:41:12: note: because 'OrthodoxTest::Value' has user-provided 'OrthodoxTest::Value& OrthodoxTest::Value::operator=(const OrthodoxTest::Value&)'
[  114s]    41 |     Value& operator= ( const Value& v )
[  114s]       |            ^~~~~~~~
[  115s] g++ -DHAVE_CONFIG_H -I. -I../..  -I../../include -I../../include   -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Werror -Wall -Wextra -pedantic -c -o SubclassedTestCase.o SubclassedTestCase.cpp
[  116s] g++ -DHAVE_CONFIG_H -I. -I../..  -I../../include -I../../include   -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Werror -Wall -Wextra -pedantic -c -o TestAssertTest.o TestAssertTest.cpp
[  117s] g++ -DHAVE_CONFIG_H -I. -I../..  -I../../include -I../../include   -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Werror -Wall -Wextra -pedantic -c -o TestCallerTest.o TestCallerTest.cpp
[  119s] g++ -DHAVE_CONFIG_H -I. -I../..  -I../../include -I../../include   -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Werror -Wall -Wextra -pedantic -c -o TestCaseTest.o TestCaseTest.cpp
Comment 1 Xisco Faulí 2019-02-12 17:00:55 UTC
@Stephan Bergmann, any opinion here ?
Comment 2 Stephan Bergmann 2019-02-13 12:19:44 UTC
Yes, that likely needs fixing, probably similarly to <https://gerrit.libreoffice.org/plugins/gitiles/cppunit/+/4f5cd3b486afb9c7be1903252b4ae3787137a454%5E%21> "Avoid GCC 9 -Wdeprecated-copy
".  (I had only fixed those -Wdeprecated-copy in CppUnit source code that were encountered when compiling LibreOffice test code that uses CppUnit, and that TestSuiteBuilderContextBase was the only issue there.)
Comment 3 Martin Liška 2019-03-07 14:04:18 UTC
(In reply to Stephan Bergmann from comment #2)
> Yes, that likely needs fixing, probably similarly to
> <https://gerrit.libreoffice.org/plugins/gitiles/cppunit/+/
> 4f5cd3b486afb9c7be1903252b4ae3787137a454%5E%21> "Avoid GCC 9
> -Wdeprecated-copy
> ".  (I had only fixed those -Wdeprecated-copy in CppUnit source code that
> were encountered when compiling LibreOffice test code that uses CppUnit, and
> that TestSuiteBuilderContextBase was the only issue there.)

Yes, that's exactly very similar issue. Can you please prepare a fix for it?
Thanks.
Comment 4 Martin Liška 2019-03-11 13:43:23 UTC
There's a patch candidate, can you please merge it:

diff --git a/examples/cppunittest/OrthodoxTest.h b/examples/cppunittest/OrthodoxTest.h
index 8fc2a08..3781415 100644
--- a/examples/cppunittest/OrthodoxTest.h
+++ b/examples/cppunittest/OrthodoxTest.h
@@ -37,6 +36,7 @@ private:
   {
   public:
     Value( int value =0 ) : m_value( value ) {}
+    Value( const Value &other) : m_value ( other.m_value ) {}
 
     Value& operator= ( const Value& v )
     {
@@ -143,6 +143,12 @@ private:
     {
       return ValueBadCall( -1 - m_value );
     }
+
+    ValueBadCall &operator =( const ValueBadCall &other)
+    {
+      m_value = other.m_value;
+      return *this;
+    }
   };
 
 
@@ -150,6 +156,9 @@ private:
   {
   public:
     ValueBadAssignment( int value =0 ) : Value( value ) {}
+    ValueBadAssignment( const ValueBadAssignment &other): Value (other.m_value)
+    {
+    }
 
     ValueBadAssignment operator !()
     {
Comment 5 Xisco Faulí 2019-03-14 20:58:43 UTC
@Markus Mohrhard, how patches can be submitted to cppunit? gerrit ?
Comment 6 Martin Liška 2019-04-25 10:50:11 UTC
May I please remind the patch candidate?
Comment 7 Tomáš Chvátal 2019-04-29 14:01:38 UTC
Shouldn't this be already fixed by:

https://cgit.freedesktop.org/libreoffice/cppunit/commit/?id=4f5cd3b486afb9c7be1903252b4ae3787137a454
Comment 8 Martin Liška 2019-04-29 14:03:06 UTC
(In reply to Tomáš Chvátal from comment #7)
> Shouldn't this be already fixed by:
> 
> https://cgit.freedesktop.org/libreoffice/cppunit/commit/
> ?id=4f5cd3b486afb9c7be1903252b4ae3787137a454

I guess so, closing as fixed.
Comment 9 Martin Liška 2019-04-29 14:14:23 UTC
(In reply to Martin Liška from comment #8)
> (In reply to Tomáš Chvátal from comment #7)
> > Shouldn't this be already fixed by:
> > 
> > https://cgit.freedesktop.org/libreoffice/cppunit/commit/
> > ?id=4f5cd3b486afb9c7be1903252b4ae3787137a454
> 
> I guess so, closing as fixed.

So no, similar changes need to be done as mentioned in:
https://bugs.documentfoundation.org/show_bug.cgi?id=122605#c3
Comment 10 Xisco Faulí 2019-04-30 10:02:36 UTC
(In reply to Martin Liška from comment #9)
> (In reply to Martin Liška from comment #8)
> > (In reply to Tomáš Chvátal from comment #7)
> > > Shouldn't this be already fixed by:
> > > 
> > > https://cgit.freedesktop.org/libreoffice/cppunit/commit/
> > > ?id=4f5cd3b486afb9c7be1903252b4ae3787137a454
> > 
> > I guess so, closing as fixed.
> 
> So no, similar changes need to be done as mentioned in:
> https://bugs.documentfoundation.org/show_bug.cgi?id=122605#c3

Would you like to provide a patch for it ?
Comment 11 Martin Liška 2019-04-30 10:03:52 UTC
(In reply to Xisco Faulí from comment #10)
> (In reply to Martin Liška from comment #9)
> > (In reply to Martin Liška from comment #8)
> > > (In reply to Tomáš Chvátal from comment #7)
> > > > Shouldn't this be already fixed by:
> > > > 
> > > > https://cgit.freedesktop.org/libreoffice/cppunit/commit/
> > > > ?id=4f5cd3b486afb9c7be1903252b4ae3787137a454
> > > 
> > > I guess so, closing as fixed.
> > 
> > So no, similar changes need to be done as mentioned in:
> > https://bugs.documentfoundation.org/show_bug.cgi?id=122605#c3
> 
> Would you like to provide a patch for it ?

Already done:
https://gerrit.libreoffice.org/#/c/71573/
Comment 12 Xisco Faulí 2019-08-06 14:30:18 UTC
A polite ping to Martin Liška:
Is this bug fixed? if so, could you please close it as RESOLVED FIXED ? Otherwise, Could you please explain what's missing?
Thanks
Comment 13 Martin Liška 2019-08-06 14:31:32 UTC
Yep, I'm closing that as resolved.