Skip to content

Incorrect order of base-class initializers in class template [GH #302] - #318

Merged
nv-cmeerw merged 1 commit into
mainfrom
fix/302
Oct 19, 2026
Merged

nv-cmeerw merged 1 commit into
mainfrom
fix/302

Conversation

@nv-cmeerw

Copy link
Copy Markdown
Contributor

Fixes #302

Incorrect order of base-class initializers in class template

Previously, in the IL for prototype instantiations of class templates,
base-class mem-initializers with non-type template arguments could appear after
the initializers for other base classes. Such initializers are now recorded in
base-class declaration order when the base class can be identified.
Initializers for base classes that cannot yet be identified now retain their
source order relative to the next initializer for an identified nonvirtual
direct base class. For example, with --c++11:

  template<int> struct A { };
  struct B { };
  template<int N> struct C : A<N>, B {
    C() : A<N>(), B() { }      // Previously recorded as "B(), A<N>()".
    C(int) : A<+N>(), B() { }  // Previously recorded as "B(), A<+N>()".
  };

Both initializer lists are now recorded in the order shown.

@daveedvdv-nvidia daveedvdv-nvidia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nv-cmeerw
nv-cmeerw merged commit 5bfce0a into main Oct 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependent NTTP base mem-initializer emitted out of declaration order

2 participants