You are not logged in.

#1 2017-05-31 12:32:04

immanuel
Member
Registered: 2017-05-31
Posts: 4

[SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Hello all,

first time posting here. Hope it's the right place.

I have a few projects where I use std::unordered_map provided by gcc-libs aka libstdc++. Since upgrading gcc-libs from previously 6.3.1-2 to 7.1.1-2 I get the following error message when compiling translation units using std::unordered_map.

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:27: error: use of class template 'optional' requires template arguments
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:451:11: note: template is declared here
    class optional
          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:40: error: expected ';' at end of declaration
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                                       ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:41: error: cannot use arrow operator on a type
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;

The compile flags are

-std=c++1z -W -Wall -pedantic

I am looking forward to your help.

Regards,
Immanuel

Last edited by immanuel (2017-05-31 14:28:31)

Offline

#2 2017-05-31 12:55:54

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Can you supply a minimal example?

Offline

#3 2017-05-31 13:17:47

immanuel
Member
Registered: 2017-05-31
Posts: 4

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Compile this code

/*-- demo.cpp --*/
#include <unordered_map>

int main()
{
    return 0;
}

with

clang++ -std=c++1z -W -Wall -pedantic demo.cpp

I forgot to mention i use clang. It does compile properly with gcc, though.

Offline

#4 2017-05-31 13:58:12

immanuel
Member
Registered: 2017-05-31
Posts: 4

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Aha, it seems this is due to differences in clang and gcc. Please inspect the following code snippet:

template<typename T>
struct optional { };

template<typename T> optional(T) -> optional<T>;

int main()
{
    return 0;
}

This compiles with g++ but not with clang++ (yielding the same error message(s)). I again use the compile flags

-std=c++1z -W -Wall -pedantic

Now what is the meaning of the 4th line?

template<typename T> optional(T) -> optional<T>;

AFAIK C++11 introduced an alternate function syntax with a "trailing-return-type". But then the keyword "auto" is required before the function name. So i guess it is a class template deduction guide [1], introuced in C++17 and which i was not aware of until now. I suppose clang 4.0.0 does not support this language feature yet hmm

[1] http://en.cppreference.com/w/cpp/langua … _deduction

Offline

#5 2017-05-31 14:02:48

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

immanuel wrote:

I suppose clang 4.0.0 does not support this language feature yet hmm

You should be able to post this upstream as a feature request, if you so desire. I'ver never used clang (haven't needed to) so I don't know for certain. But it couldn't hurt to ask the clang devs. smile


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#6 2017-05-31 14:26:54

immanuel
Member
Registered: 2017-05-31
Posts: 4

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

@JohnBobSmith it seems this is the way to go.

Anyways, everyone who uses clang together with libstdc++ and tries to compile a TU including <optional> will run into this issue. So clang will have to support this or break compatibility.
For now, i just commented that particular line

template <typename _Tp> optional(_Tp) -> optional<_Tp>;

in include/c++/7.1.1/optional:1032:27.

Thanks for the help, guys.
Best,
Immanuel

Last edited by immanuel (2017-05-31 14:30:13)

Offline

#7 2017-06-02 19:30:54

iamsergio
Member
Registered: 2017-06-02
Posts: 2

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Why is this marked as solved ?

An archlinux bug report should be opened and our clang 4.0 patched.

Offline

#8 2017-06-02 19:38:41

iamsergio
Member
Registered: 2017-06-02
Posts: 2

Re: [SOLVED] Upgrading gcc-libs 6.3.1-2 to 7.1.1-2 breaks unordered_map

Offline

Board footer

Powered by FluxBB