Informix Error -405
-405 The Address of a host variable is not properly aligned.
Review the way the program constructs the sqlda and related data structures; somehow it is setting up a pointer that is not word aligned. Also, make sure that all host variables are aligned on proper address boundaries for their types. If the program is in IBM Informix 4GL or another language in which the programmer has no control over storage alignments, this error should not occur. If the error recurs, note all circumstances and contact IBM Informix Technical Support.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-405 is closely related to -402: another embedded-SQL/ESQL-C client-programming error
involving improper sqlda construction, but here the specific problem is memory alignment — a
host variable's address doesn't fall on the address boundary its data type requires (e.g. a
4-byte-aligned boundary for a 4-byte integer).
- A manually constructed
sqldapointing at a host variable whose actual memory address isn't aligned for its declared type — typically from low-level pointer arithmetic gone wrong. - A host variable declared inside a packed/unaligned structure in C, where compiler-level packing pragmas remove the natural alignment the SQL layer expects.
- Casting between incompatible pointer types in client code, producing an address that satisfies the C compiler but not the underlying data type's natural alignment requirement.
Solutions / Resolution
- Ensure host variables are declared normally, without unusual packing or casting that would break their natural memory alignment, per the official guidance.
- Review manually constructed
sqldastructures for pointer arithmetic that could produce a misaligned address. - If using a higher-level language (4GL and similar) where this shouldn't normally occur, treat its appearance as a signal of a runtime or generated-code bug, not an application input mistake.
- If the problem persists after reviewing host-variable declarations and
sqldaconstruction, contact IBM Informix Technical Support, per the official guidance.
Examples
Avoiding packed structures for host variables
/* Avoid #pragma pack or __attribute__((packed)) on structs
containing host variables passed to embedded SQL statements —
it can break the natural alignment the SQL layer expects. */
struct {
int order_id;
char status[20];
} host_vars;
Reviewing manual sqlda pointer construction
/* Confirm any manually computed host-variable address in a
custom sqlda actually falls on the correct alignment boundary
for its declared type, rather than an arbitrary byte offset. */
Diagnostic Checks
- Check for packed/unaligned struct declarations containing host variables used in embedded SQL statements.
- Review any manual
sqldaconstruction for pointer arithmetic that could misalign an address. - Confirm whether the client code is a higher-level language (4GL and similar) where this shouldn't normally occur at all.
Related Errors / Related Topics
- -402 — "Address of a host variable is NULL." The closely related sibling — both concern
improperly constructed
sqlda/host-variable-address structures in embedded SQL/ESQL-C client code. - -403 — "The size of a received row disagrees with the expected size." Another client/server-communication-level error, though about a size mismatch rather than address alignment.
Avoid packed/unaligned struct declarations and manual pointer arithmetic around host variables used in embedded SQL — this shouldn't occur at all in higher-level languages like 4GL.