You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Noory, Robert" <Ro...@grassvalley.com> on 2018/12/21 15:33:27 UTC

Issue with log4cxx and gcc 7.3

Hi,


I found an issue with log4cxx built from sources on Ubuntu 18.04 (gcc 7.3).  When I execute "make check", I get the error shown below.

I attached a simple patch to fix the issue.  The detailed info is below:

  *   Host: Ubuntu 18.04.1 LTS
  *   gcc: gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
  *   repository: master branch (171e980fdd31e09e36841) on http://gitbox.apache.org/repos/asf/logging-log4cxx.git

Thank you



ERROR:

---------------------------------------------------------------------------------------------------------------------------------------------------------

make[4]: Entering directory '/home/me/projects/basics/logging-log4cxx/src/test/cpp'
depbase=`echo helpers/transcodertestcase.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -DPACKAGE_NAME=\"log4cxx\" -DPACKAGE_TARNAME=\"log4cxx\" -DPACKAGE_VERSION=\"0.11.0\" -DPACKAGE_STRING=\"log4cxx\ 0.11.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"log4cxx\" -DVERSION=\"0.11.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_MBSRTOWCS=1 -DHAVE_WCSTOMBS=1 -DHAVE_SYSLOG=1 -DHAVE_FWIDE=1 -I.  -I../../../src/main/include -I../../../src/main/include -DLINUX -D_REENTRANT -D_GNU_SOURCE  -I/usr/include/apr-1.0   -I/usr/local/apr/include/apr-1   -g -O2 -MT helpers/transcodertestcase.o -MD -MP -MF $depbase.Tpo -c -o helpers/transcodertestcase.o helpers/transcodertestcase.cpp &&\
mv -f $depbase.Tpo $depbase.Po
helpers/transcodertestcase.cpp: In member function 'void TranscoderTestCase::encodeCharsetName3()':
helpers/transcodertestcase.cpp:334:68: error: narrowing conversion of '128' from 'int' to 'log4cxx::logchar {aka char}' inside { } [-Wnarrowing]
             logchar unsupported[] = { 0x1F, 0x7F, 0x80, 0x81, 0x00 };
                                                                    ^
helpers/transcodertestcase.cpp:334:68: error: narrowing conversion of '129' from 'int' to 'log4cxx::logchar {aka char}' inside { } [-Wnarrowing]
Makefile:994: recipe for target 'helpers/transcodertestcase.o' failed

---------------------------------------------------------------------------------------------------------------------------------------------------------


PATCH:

diff --git a/src/test/cpp/helpers/transcodertestcase.cpp b/src/test/cpp/helpers/transcodertestcase.cpp
index 6eafc150..32aafe13 100644
--- a/src/test/cpp/helpers/transcodertestcase.cpp
+++ b/src/test/cpp/helpers/transcodertestcase.cpp
@@ -331,7 +331,7 @@ public:
         }

         void encodeCharsetName3() {
-            logchar unsupported[] = { 0x1F, 0x7F, 0x80, 0x81, 0x00 };
+            logchar unsupported[] = { 0x1F, 0x7F, (logchar)0x80, (logchar)0x81, 0x00 };
             std::string encoded(Transcoder::encodeCharsetName(LogString(unsupported)));
             LOGUNIT_ASSERT_EQUAL(std::string("????"), encoded);
         }

**********************************************************************
DISCLAIMER:
Privileged and/or Confidential information may be contained in this message. If you are not the addressee of this message, you may not copy, use or deliver this message to anyone. In such event, you should destroy the message and kindly notify the sender by reply e-mail. It is understood that opinions or conclusions that do not relate to the official business of the company are neither given nor endorsed by the company. Thank You.

Re: Issue with log4cxx and gcc 7.3

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Valentina Ichimov,
am Donnerstag, 21. Februar 2019 um 17:36 schrieben Sie:

> I want to unsubscribe from here.

All mails from the list contain the following header, just have a look
at those or the source code of the mail in your client to manage your
subscription:

> List-Unsubscribe: <ma...@logging.apache.org>

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: Issue with log4cxx and gcc 7.3

Posted by Valentina Ichimov <vi...@gmail.com>.
Hello,

I want to unsubscribe from here.

thank you

On Thu, Feb 21, 2019 at 6:09 PM Nathaniel W. Turner <na...@houseofnate.net>
wrote:

> Wait, isn't the compiler trying to remind us that 0x80 does not actually
> fit in a char? (It doesn't.) Wouldn't the correct fix actually be to define
> log4cxx::logchar as unsigned char, instead of char?
>
> On Thu, Feb 21, 2019 at 5:44 AM Thorsten Schöning <ts...@am-soft.de>
> wrote:
>
> > Guten Tag Noory, Robert,
> > am Freitag, 21. Dezember 2018 um 16:33 schrieben Sie:
> >
> > > I found an issue with log4cxx built from sources on Ubuntu 18.04
> > > (gcc 7.3).  When I execute "make check", I get the error shown below.
> >
> > Thanks for reporting. The problem should be fixed now using the same
> > approach like in the past instead of applying your patch directly,
> > simply to be more consistent.
> >
> > https://issues.apache.org/jira/browse/LOGCXX-400
> >
> > Mit freundlichen Grüßen,
> >
> > Thorsten Schöning
> >
> > --
> > Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
> > AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
> >
> > Telefon...........05151-  9468- 55
> > Fax...............05151-  9468- 88
> > Mobil..............0178-8 9468- 04
> >
> > AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> > AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
> >
> >
>

Re: Issue with log4cxx and gcc 7.3

Posted by "Nathaniel W. Turner" <na...@gmail.com>.
Ah, that's too bad!
Thanks for investigating the feasibility.

On Fri, Feb 22, 2019, 6:05 AM Thorsten Schöning <ts...@am-soft.de>
wrote:

> Guten Tag Nathaniel W. Turner,
> am Donnerstag, 21. Februar 2019 um 17:02 schrieben Sie:
>
> > Wait, isn't the compiler trying to remind us that 0x80 does not actually
> > fit in a char? (It doesn't.)
>
> From my understanding, a "char" holds 8 bits of data and 0x80 only
> consumes at most that 8 bits in the contexts log4cxx cared about in
> the past, so the value does fit. What the compiler is telling me is
> that I won't necessarily get the decimal 128 back, but as this is used
> as some UTF-8 byte, I don't think we care much.
>
> > Wouldn't the correct fix actually be to define
> > log4cxx::logchar as unsigned char, instead of char?
>
> While it might be the formal correct approach, it doesn't seem to be
> worth it: Using std::basic_string<char> to store UTF-8 seems to be OK
> currently for most of the world and if that is changed to "unsigned
> char", a lot of things internally in log4cxx break. Not only regarding
> strings, but bytes as well, because those worlds are not as clearly
> seperated as one would expect currently. Additionally, one would get a
> lot of incompatibility using interfaces like those of APR, which are
> "char*" currently most of the time as well.
>
> I spent some hours yesterday to test this and ended up in a lot of
> additional CASTs or one might even need to really convert data from
> "char" to "unsigned char" for formal reasons, where things were simply
> forwarded as is before.
>
> So, I've documented my findings and won't change to "unsigned" for
> now.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>

Re: Issue with log4cxx and gcc 7.3

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Nathaniel W. Turner,
am Donnerstag, 21. Februar 2019 um 17:02 schrieben Sie:

> Wait, isn't the compiler trying to remind us that 0x80 does not actually
> fit in a char? (It doesn't.)

From my understanding, a "char" holds 8 bits of data and 0x80 only
consumes at most that 8 bits in the contexts log4cxx cared about in
the past, so the value does fit. What the compiler is telling me is
that I won't necessarily get the decimal 128 back, but as this is used
as some UTF-8 byte, I don't think we care much.

> Wouldn't the correct fix actually be to define
> log4cxx::logchar as unsigned char, instead of char?

While it might be the formal correct approach, it doesn't seem to be
worth it: Using std::basic_string<char> to store UTF-8 seems to be OK
currently for most of the world and if that is changed to "unsigned
char", a lot of things internally in log4cxx break. Not only regarding
strings, but bytes as well, because those worlds are not as clearly
seperated as one would expect currently. Additionally, one would get a
lot of incompatibility using interfaces like those of APR, which are
"char*" currently most of the time as well.

I spent some hours yesterday to test this and ended up in a lot of
additional CASTs or one might even need to really convert data from
"char" to "unsigned char" for formal reasons, where things were simply
forwarded as is before.

So, I've documented my findings and won't change to "unsigned" for
now.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: Issue with log4cxx and gcc 7.3

Posted by "Nathaniel W. Turner" <na...@houseofnate.net>.
Wait, isn't the compiler trying to remind us that 0x80 does not actually
fit in a char? (It doesn't.) Wouldn't the correct fix actually be to define
log4cxx::logchar as unsigned char, instead of char?

On Thu, Feb 21, 2019 at 5:44 AM Thorsten Schöning <ts...@am-soft.de>
wrote:

> Guten Tag Noory, Robert,
> am Freitag, 21. Dezember 2018 um 16:33 schrieben Sie:
>
> > I found an issue with log4cxx built from sources on Ubuntu 18.04
> > (gcc 7.3).  When I execute "make check", I get the error shown below.
>
> Thanks for reporting. The problem should be fixed now using the same
> approach like in the past instead of applying your patch directly,
> simply to be more consistent.
>
> https://issues.apache.org/jira/browse/LOGCXX-400
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>

Re: Issue with log4cxx and gcc 7.3

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Noory, Robert,
am Freitag, 21. Dezember 2018 um 16:33 schrieben Sie:

> I found an issue with log4cxx built from sources on Ubuntu 18.04
> (gcc 7.3).  When I execute "make check", I get the error shown below.

Thanks for reporting. The problem should be fixed now using the same
approach like in the past instead of applying your patch directly,
simply to be more consistent.

https://issues.apache.org/jira/browse/LOGCXX-400

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow