GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Alexander Monakov (amonakov@mastodon.gamedev.place)'s status on Friday, 24-Jan-2025 19:15:29 JST Alexander Monakov Alexander Monakov

    Let's say a C program comprises two translation units, each of which declares the following type:

    struct list {
    struct list *next;
    void *payload;
    };

    For deciding whether they are compatible, the following clause of the language standard applies:

    "there shall be a one-to-one correspondence between their members such that each pair of corresponding members are declared with compatible types;"

    Apparently the implementation may claim that such self-referential types are not compatible! 🙃

    In conversation about 4 months ago from mastodon.gamedev.place permalink
    • Embed this notice
      Wolf480pl (wolf480pl@mstdn.io)'s status on Friday, 24-Jan-2025 19:15:26 JST Wolf480pl Wolf480pl
      in reply to

      @amonakov what I'm saying is major compilers can abuse every loophole in the spec and if they decide to do so, there's no convincing them to stop

      In conversation about 4 months ago permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Wolf480pl (wolf480pl@mstdn.io)'s status on Friday, 24-Jan-2025 19:15:27 JST Wolf480pl Wolf480pl
      in reply to

      @amonakov depends. Is the implementation's name "clang" or "gcc"?

      In conversation about 4 months ago permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Alexander Monakov (amonakov@mastodon.gamedev.place)'s status on Friday, 24-Jan-2025 19:15:27 JST Alexander Monakov Alexander Monakov
      in reply to
      • Wolf480pl

      @wolf480pl I'm probably missing what you're hinting at, but to me the most "interesting" (but not really) question is what choice an implementation aiming to detect many instances of UB, such as TIS-interpreter, would make.

      In conversation about 4 months ago permalink
    • Embed this notice
      Alexander Monakov (amonakov@mastodon.gamedev.place)'s status on Friday, 24-Jan-2025 19:15:28 JST Alexander Monakov Alexander Monakov
      in reply to

      Now suppose the program contains not two, but three such translation units. Let's say the instances of the struct type are A, B, and C. Can the implementation choose to A be compatible with B, B with C, but C incompatible with A?

      In conversation about 4 months ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Friday, 24-Jan-2025 23:14:35 JST Rich Felker Rich Felker
      in reply to

      @amonakov Not specific to your example, but yes compatibility of structs is non transitive. We intentionally make use of something like this in the musl c11 thread primitives IIRC, to reuse pthread ones:

      https://git.musl-libc.org/cgit/musl/commit/?id=b7cf71a190813590860af25b32532b6c360ac502

      In conversation about 4 months ago permalink
    • Embed this notice
      Rich Felker (dalias@hachyderm.io)'s status on Saturday, 25-Jan-2025 00:07:55 JST Rich Felker Rich Felker
      in reply to

      @amonakov Maybe this isn't quite the same thing, but it's related. I'll think about it more.

      In conversation about 4 months ago permalink
    • Embed this notice
      Alexander Monakov (amonakov@mastodon.gamedev.place)'s status on Saturday, 25-Jan-2025 00:07:56 JST Alexander Monakov Alexander Monakov
      in reply to
      • Rich Felker

      @dalias I do not see how this relates to [non-]transitivity. What would be the hypothetical third struct that would be compatible with exactly one of pthread_mutex_t and mtx_t?

      Generally speaking, do you have an example that illustrates non-transitivity of compatibility relation that does not involve unprototyped function type?

      In conversation about 4 months ago permalink

Feeds

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

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.