Giter Site home page Giter Site logo

Comments (7)

usagi avatar usagi commented on May 16, 2024
b[std::slice(0,2,3)] = {'x','y'};

b[std::slice(0,2,3)] = a_type({'x','y'});

コンパイル時に明示的にa_type型にしてあげればClang-HEADでも期待通りの結果が得られますね。

この問題の直接の原因は {'x','y'} を std::valarray の std::slice の operator= がClang-HEADではstd::valarrayに型変換されてくれない挙動のようです。

cpprefjpとしての問題は、このClangの挙動({'x','y'}をstd::valarray型に暗黙的に変換しない)がC++規格として正しいか、という事になるかと思います。

さしあたりは、Clang-HEADでコンパイルできない事の解決としても、明示的なコードとしても、冒頭に挙げたClang-HEADでもコンパイル可能なパターンへの変更をpull-reqしておきます。

from site.

kariya-mitsuru avatar kariya-mitsuru commented on May 16, 2024

libc++ の問題のように見えますね。
slice_array には

void operator=(const valarray<T>&) const;

が無きゃならないのに、libc++ には

template <class _Expr>
typename enable_if<__is_val_expr<_Expr>::value, void>::type operator=(const _Expr& __v) const;

しかないです。
operator= の引数がテンプレートパラメータなので、initializer_list から valarray への暗黙変換がされないのではないかと思います。
試しに {'x','y'}std::valarray<v_type>{'x','y'} に変更したら clang & libc++ でもコンパイルできました。

http://melpon.org/wandbox/permlink/KSMdklUGHtL9oQWJ

from site.

kariya-mitsuru avatar kariya-mitsuru commented on May 16, 2024

あ、かぶった…
そして a_type ありましたね…orz
上に書いたとおり、clang でも libstdc++ 使えばコンパイルできます。

from site.

usagi avatar usagi commented on May 16, 2024

本来は元のままでもコンパイルされて然るべき、とは言え最新のClang++というかlibc++で通らないサンプルを注釈を付けて掲載するのもユーザーフレンドリーではありませんし、hotfixの対応はそれほど複雑化するものではないので、どなたか確認頂いた上でさしあたりはpull-reqの修正をmergeして頂ければいいかな、と思います。

と、同時にlibc++にバグ報告を挙げるべきででしょうか。

※只今よりお仕事タイム的にしばらくスレッドに出没できなくなります。夕方以降にまたスレッド確認します。

from site.

melpon avatar melpon commented on May 16, 2024

バグ報告が終わったら Close する方向で。

from site.

kariya-mitsuru avatar kariya-mitsuru commented on May 16, 2024

バグレポの栄誉頂きました!

http://llvm.org/bugs/show_bug.cgi?id=17814

#英文は気にしない方向で…

from site.

melpon avatar melpon commented on May 16, 2024

ありがとうございます!
valarray のコードは修正されたし、バグ報告もしたので、これで問題は解決したということで Close します。

from site.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.