will be initialized after C/C++ Origin: Application & API OSI layer 7 · Application Last updated 28 Nov 2026

C++: warning: 'X::a' will be initialized after 'X::b' [-Wreorder]

Members are initialised in declaration order, not in the order of the constructor's initialiser list.

Exact message you may see will be initialized aftermember initializer order
Seen on: C/C++ GCC Clang

Meaning

If one member's initialiser uses another that is declared later, it reads an uninitialised value. Reorder the list or the declarations.

Common causes

  • Initialiser list order differs from declaration order
  • Member depends on a later one

⚡ Quick fix

  1. Match the initialiser order to the declaration order
  2. Move declarations

Detailed fix by platform

GCC / Clang

  1. Keep -Wreorder on and fix the order

Code examples

dependent members

cpp
struct S { int a; int b; S() : b(1), a(b + 1) {} };   // a initialised first using uninitialised b

How to diagnose

  1. Order — Same order?
  2. Dependency — Does one use the other?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

address of local variable returned — C/C++: warning: address of local variable 'x' returned [-Wreturn-local-addr] (C/C++)address of local vari…C2512 — MSVC: error C2512: 'X': no appropriate default constructor available (C/C++)C2512implicitly deleted — C++: error: call to implicitly-deleted default constructor of 'X' (C/C++)implicitly deletedincompatible pointer type — C: warning/error: passing argument from incompatible pointer type [-Wincompatible-pointer-types] (C/C++)incompatible pointer …ISO C++ forbids converting a string constant — C++: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] (C/C++)ISO C++ forbids conve…makes pointer from integer without a cast — C: warning: assignment makes pointer from integer without a cast (C/C++)makes pointer from in…may be used uninitialized — C/C++: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized] (C/C++)may be used uninitial…will be i…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.