Skip to content

has_unique_object_representations returns false for classes whose base has only inherited members #327

Open

Description

@nv-cmeerw

Discussed in #290

Originally posted by jakub-labenski October 13, 2026

Issue Summary

type_has_unique_object_representations (folding.c) treats a direct base class as empty when its own field_list is NULL, ignoring the data inherited from its bases. Such a base contributes 0 bytes to the computed layout, so the tail-padding check fails and the trait wrongly evaluates to false.

Observed Behavior

Reproducer:

//remark:type_has_unique_object_representations
//options:--g++ --gnu_version=150100;fp
struct A { char i; };
struct B : A {};
struct C : B {};
static_assert(__has_unique_object_representations(B));  // passes
static_assert(__has_unique_object_representations(C));  // fails, expected to pass

edg-docker-test and then edg-test-run-diff returns:

--- Expected Output (sandbox/test.sft.rt.tar.gz -- edg_x86_64)
+++ Observed Output (sandbox/test.sft.rt.tar.gz -- edg_x86_64)
# fe_only -DTEST_NUMBER=1 --g++ --gnu_version=150100 Test_name.c
@@ -0,0 +1,5 @@
+"Test_name.c", line 7: error: static assertion failed
+  static_assert(__has_unique_object_representations(C));  // fails, expected to pass
+  ^
+
+1 error detected in the compilation of "Test_name.c".

Expected Behavior

Code should compile correctly.

Additional Details

No response

I acknowledge that:

  • I have checked open issues and existing discussions before filing this report.

Activity

  1. added a commit that references this issue on Nov 9, 2026
  2. mohitmishra786 commented on Nov 14, 2026

    @mohitmishra786
    Contributor

    @wchilders-nvidia @nv-cmeerw this looks fixed on main by 98ad882 (#326), and __has_unique_object_representations(C) from the report is now true. Could this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions