Bug 432639 - Konsole needs gcc > 8.3 (fully supporting C++17) for for_each_n function
Summary: Konsole needs gcc > 8.3 (fully supporting C++17) for for_each_n function
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (other bugs)
Version First Reported In: master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
: 433043 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-02-08 12:48 UTC by rcorreia31
Modified: 2021-02-19 02:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
attachment-6821-0.html (3.51 KB, text/html)
2021-02-08 12:55 UTC, tcanabrava
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rcorreia31 2021-02-08 12:48:46 UTC
SUMMARY
By default CentOS 8.3 uses gcc 8.3.1.
Konsole from master now fails due to this error:
/media/MyPassport/git/konsole/src/Screen.cpp: In function 'void toDebug(const Konsole::Character*, int, bool)':
/media/MyPassport/git/konsole/src/Screen.cpp:394:10: error: 'for_each_n' is not a member of 'std'
     std::for_each_n(s, count, [&out](const Character &i) { out += i.character; });
          ^~~~~~~~~~
/media/MyPassport/git/konsole/src/Screen.cpp:394:10: note: suggested alternative: 'for_each'
     std::for_each_n(s, count, [&out](const Character &i) { out += i.character; });
          ^~~~~~~~~~
          for_each

To be able to compile, another tool chain fully supporting C++17 must be installed and enabled: dnf install gcc-toolset-10-toolchain (or gcc-toolset-9-toolchain).
Then all compiles well.
This is the first time this requirement appears for KDE from what I can tell.

A link about that: https://github.com/VcDevel/Vc/issues/182

Even if this is easily fixed with a newer toolchain, it will cause some questions.

STEPS TO REPRODUCE
1. cmake
2. make

OBSERVED RESULT
Compilation error: 
/git/konsole/src/Screen.cpp:394:10: error: 'for_each_n' is not a member of 'std'
/git/konsole/src/Screen.cpp:394:10: note: suggested alternative: 'for_each'

EXPECTED RESULT
Change to a source code allowing a successful compilation with gcc 8.3.x or add a cmake check explaining this new requirement (dnf install gcc-toolset-10-toolchain or dnf install gcc-toolset-9-toolchain).

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.20.2
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.1
Comment 1 tcanabrava 2021-02-08 12:55:47 UTC
Created attachment 135505 [details]
attachment-6821-0.html

can you provide a patch?
c++17 is 4 years old and I don't really like to fix compiler bugs, even
though I know that gcc 8.4 was released just last year and that's not a lot
of time for linux  distros to pick it up.


On Mon, Feb 8, 2021 at 12:48 PM <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=432639
>
>             Bug ID: 432639
>            Summary: Konsole needs gcc > 8.3 (fully supporting C++17) for
>                     for_each_n function
>            Product: konsole
>            Version: master
>           Platform: Compiled Sources
>                 OS: Linux
>             Status: REPORTED
>           Severity: normal
>           Priority: NOR
>          Component: general
>           Assignee: konsole-devel@kde.org
>           Reporter: rcorreia31@gmail.com
>   Target Milestone: ---
>
> SUMMARY
> By default CentOS 8.3 uses gcc 8.3.1.
> Konsole from master now fails due to this error:
> /media/MyPassport/git/konsole/src/Screen.cpp: In function 'void
> toDebug(const
> Konsole::Character*, int, bool)':
> /media/MyPassport/git/konsole/src/Screen.cpp:394:10: error: 'for_each_n'
> is not
> a member of 'std'
>      std::for_each_n(s, count, [&out](const Character &i) { out +=
> i.character;
> });
>           ^~~~~~~~~~
> /media/MyPassport/git/konsole/src/Screen.cpp:394:10: note: suggested
> alternative: 'for_each'
>      std::for_each_n(s, count, [&out](const Character &i) { out +=
> i.character;
> });
>           ^~~~~~~~~~
>           for_each
>
> To be able to compile, another tool chain fully supporting C++17 must be
> installed and enabled: dnf install gcc-toolset-10-toolchain (or
> gcc-toolset-9-toolchain).
> Then all compiles well.
> This is the first time this requirement appears for KDE from what I can
> tell.
>
> A link about that: https://github.com/VcDevel/Vc/issues/182
>
> Even if this is easily fixed with a newer toolchain, it will cause some
> questions.
>
> STEPS TO REPRODUCE
> 1. cmake
> 2. make
>
> OBSERVED RESULT
> Compilation error:
> /git/konsole/src/Screen.cpp:394:10: error: 'for_each_n' is not a member of
> 'std'
> /git/konsole/src/Screen.cpp:394:10: note: suggested alternative: 'for_each'
>
> EXPECTED RESULT
> Change to a source code allowing a successful compilation with gcc 8.3.x
> or add
> a cmake check explaining this new requirement (dnf install
> gcc-toolset-10-toolchain or dnf install gcc-toolset-9-toolchain).
>
> SOFTWARE/OS VERSIONS
> KDE Plasma Version: 5.20.2
> KDE Frameworks Version: 5.76.0
> Qt Version: 5.15.1
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 2 Kurt Hindenburg 2021-02-18 03:07:43 UTC
*** Bug 433043 has been marked as a duplicate of this bug. ***
Comment 3 rcorreia31 2021-02-18 07:18:15 UTC
API for_each is well compiled by gcc 8.3.1

I am not familiar with C++ development but from what I see from for_each_n and 
for_each specifications, the main difference is the second parameter.

For for_each_n, this is a count whether for for_each it is a last/max value.
So may be:
 std::for_each (s, s+count, [&out](const Character &i) { out += i.character; });
It compiles but I don't know how to check if it really does what is expected from this toDebug function.
Comment 4 Kurt Hindenburg 2021-02-19 02:23:56 UTC
Git commit 52a9df577d0b06597a016a623fc9f4c32cb917f9 by Kurt Hindenburg.
Committed on 19/02/2021 at 02:23.
Pushed by hindenburg into branch 'master'.

Comment out auxiliar functions to test Screen

for_each_n() doesn't compile w/ gcc 8.3.x

M  +5    -2    src/Screen.cpp

https://invent.kde.org/utilities/konsole/commit/52a9df577d0b06597a016a623fc9f4c32cb917f9