senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. 艮 鮟鱇 (anqou@mstdn.anqou.net)'s status on Saturday, 30-Oct-2021 23:34:31 JST 艮 鮟鱇 艮 鮟鱇

    今日のおもしろコードですhttps://wandbox.org/permlink/CqlO5tdtYDgGMzbw

    In conversation Saturday, 30-Oct-2021 23:34:31 JST from mstdn.anqou.net permalink
    • 艮 鮟鱇 (anqou@mstdn.anqou.net)'s status on Saturday, 30-Oct-2021 23:34:31 JST 艮 鮟鱇 艮 鮟鱇
      in reply to

      gccとclangで挙動が違うC++コード。多分UBを踏んでいるが、どこで踏んでいるかはいまいちよくわかっていない。

      In conversation Saturday, 30-Oct-2021 23:34:31 JST permalink
      らりお・ザ・何らかの🈗然㊌ソムリエ repeated this.
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Saturday, 30-Oct-2021 23:34:31 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      @anqou C++20 (n4868) §7.6.1.9/10https://timsong-cpp.github.io/cppwp/n4868/expr.static.cast#10

      > If the enumeration type has a fixed underlying type, the value is first converted to that type by integral conversion, if necessary, and then to the enumeration type.If the enumeration type does not have a fixed underlying type, the value is unchanged if the original value is within the range of the enumeration values ([dcl.enum]), and otherwise, the behavior is undefined.

      ここに該当して未定義動作ですね

      In conversation Saturday, 30-Oct-2021 23:34:31 JST permalink
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Saturday, 30-Oct-2021 23:42:48 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1766

      ははー、 C++11/14 では unspecified だったのが undefined になったんか

      In conversation Saturday, 30-Oct-2021 23:42:48 JST permalink
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Saturday, 30-Oct-2021 23:59:38 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      std::byte - cppreference.comhttps://en.cppreference.com/w/cpp/types/byte

      さっきのやつ <https://mstdn.anqou.net/@anqou/107190942386550421>、構図としては std::byte とほぼ同じなので、 -1 を bool に変化した true にならないとおかしい気がするんだよな……

      In conversation Saturday, 30-Oct-2021 23:59:38 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: media-mstdn.anqou.net
        艮 鮟鱇 (@anqou@mstdn.anqou.net)
        from 艮 鮟鱇
        今日のおもしろコードです https://wandbox.org/permlink/CqlO5tdtYDgGMzbw
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:04:19 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://timsong-cpp.github.io/cppwp/n4868/dcl.enum#8[dcl.enum]/8:> For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.

      > The resulting value is the same as converting the original value to the underlying type of the enumeration ([conv.fpint]), and subsequently to the enumeration type.

      https://timsong-cpp.github.io/cppwp/n4868/expr.static.cast#10[expr.static.cast]/10:> If the enumeration type has a fixed underlying type, the value is first converted to that type by integral conversion, if necessary, and then to the enumeration type.

      https://timsong-cpp.github.io/cppwp/n4868/conv.bool#1[conv.bool]/1:> A prvalue of arithmetic, unscoped enumeration, pointer, or pointer-to-member type can be converted to a prvalue of type bool.A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true.

      だよなぁ……

      In conversation Sunday, 31-Oct-2021 00:04:19 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        [dcl.enum]
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:08:31 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://timsong-cpp.github.io/cppwp/n4868/dcl.init.list#3.8[dcl.init.list]/3.8:> Otherwise, if T is an enumeration with a fixed underlying type ([dcl.enum]) U, the initializer-list has a single element v, v can be implicitly converted to U, and the initialization is direct-list-initialization, the object is initialized with the value T(v) ([expr.type.conv]); if a narrowing conversion is required to convert v to U, the program is ill-formed.

      In conversation Sunday, 31-Oct-2021 00:08:31 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        [dcl.init.list]
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:12:22 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      これは braced initializer の話で、実際 Bit{-2} したら ill-formed なのでエラーになる:

      https://wandbox.org/permlink/FJcw7RxBBa8dFWGB

      In conversation Sunday, 31-Oct-2021 00:12:22 JST permalink
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:14:51 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://timsong-cpp.github.io/cppwp/n4868/basic.fundamental#10[basic.fundamental]/10:> Type bool is a distinct type that has the same object representation, value representation, and alignment requirements as an implementation-defined unsigned integer type.The values of type bool are true and false.

      これもしかして関係あるのでは

      In conversation Sunday, 31-Oct-2021 00:14:51 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        [basic.fundamental]
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:24:26 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://timsong-cpp.github.io/cppwp/n4868/expr.type.conv#2[expr.type.conv]/2:> If the initializer is a parenthesized single expression, the type conversion expression is equivalent to the corresponding cast expression.

      In conversation Sunday, 31-Oct-2021 00:24:26 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        [expr.type.conv]
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 00:28:52 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://timsong-cpp.github.io/cppwp/n4868/expr.cast#4[expr.cast]/4> If a conversion can be interpreted in more than one of the ways listed above, the interpretation that appears first in the list is used, even if a cast resulting from that interpretation is ill-formed.

      で、 Bit(-2) は、 [expr.cast]/4.1 の const_cast ([expr.const.cast], §7.6.1.11) が該当しないから [expr.cast]/4.2 の static_cast として扱われることになるはず

      In conversation Sunday, 31-Oct-2021 00:28:52 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        [expr.cast]
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 01:00:45 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://mastodon.cardina1.red/@lo48576/107191091043504503

      この最後の "The resulting value is ..." という文は直前の "floating-point type can be also ..." にかかっていて整数から enum への場合には関係ないと考えるべきだな

      In conversation Sunday, 31-Oct-2021 01:00:45 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: mastodon.cardina1.red
        らりお・ザ・何らかの????然㊌ソムリエ (@lo48576@mastodon.cardina1.red)
        from らりお・ザ・何らかの????然㊌ソムリエ
        https://timsong-cpp.github.io/cppwp/n4868/dcl.enum#8 [dcl.enum]/8: > For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type. > The resulting value is the same as converting the original value to the underlying type of the enumeration ([conv.fpint]), and subsequently to the enumeration type. https://timsong-cpp.github.io/cppwp/n4868/expr.static.cast#10 [expr.static.cast]/10: > If the enumeration type has a fixed underlying type, the value is first converted to that type by integral conversion, if necessary, and then to the enumeration type. https://timsong-cpp.github.io/cppwp/n4868/conv.bool#1 [conv.bool]/1: > A prvalue of arithmetic, unscoped enumeration, pointer, or pointer-to-member type can be converted to a prvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true. だよなぁ……
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 02:19:51 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://mstdn.anqou.net/@anqou/107190942386550421

      まだこれのことを考えているのですが、規格追いまくってるけど implementation-defined なやつかコンパイラのバグか確定しきれずにいます (少なくとも UB ではなさそう)

      In conversation Sunday, 31-Oct-2021 02:19:51 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: media-mstdn.anqou.net
        艮 鮟鱇 (@anqou@mstdn.anqou.net)
        from 艮 鮟鱇
        今日のおもしろコードです https://wandbox.org/permlink/CqlO5tdtYDgGMzbw
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Sunday, 31-Oct-2021 06:54:10 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      @anqou 全ての謎を解いた結果、 gcc のバグであることが判明したのでおしらせします。

      基底型が bool であるような scoped enum の型変換の異常動作を追い掛けた話 - Qiitahttps://qiita.com/lo48576/items/d028280a66b77cbfa080

      In conversation Sunday, 31-Oct-2021 06:54:10 JST permalink
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Monday, 01-Nov-2021 03:03:22 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://mastodon.cardina1.red/@lo48576/107192701702283598

      分岐したスレへの補足を忘れていた

      In conversation Monday, 01-Nov-2021 03:03:22 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: mastodon.cardina1.red
        らりお・ザ・何らかの????然㊌ソムリエ (@lo48576@mastodon.cardina1.red)
        from らりお・ザ・何らかの????然㊌ソムリエ
        @anqou@mstdn.anqou.net 全ての謎を解いた結果、 gcc のバグであることが判明したのでおしらせします。 基底型が bool であるような scoped enum の型変換の異常動作を追い掛けた話 - Qiita https://qiita.com/lo48576/items/d028280a66b77cbfa080
    • らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Monday, 01-Nov-2021 03:03:28 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to

      https://mastodon.cardina1.red/@lo48576/107192701702283598

      分岐したスレへの補足を忘れていた、 UB ではなかったです

      In conversation Monday, 01-Nov-2021 03:03:28 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: mastodon.cardina1.red
        らりお・ザ・何らかの????然㊌ソムリエ (@lo48576@mastodon.cardina1.red)
        from らりお・ザ・何らかの????然㊌ソムリエ
        @anqou@mstdn.anqou.net 全ての謎を解いた結果、 gcc のバグであることが判明したのでおしらせします。 基底型が bool であるような scoped enum の型変換の異常動作を追い掛けた話 - Qiita https://qiita.com/lo48576/items/d028280a66b77cbfa080

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.