Issue 1034: Extra members in div_t types

Authors: Jay Ghiron
Date: 2026-03-20
Submitted against: C23
Status: Open

The current definitions of the division types do not clearly state whether or not they can have members other than quot or rem:

The div, ldiv, and lldiv functions return a structure of type div_t, ldiv_t, and lldiv_t, respectively, comprising both the quotient and the remainder. The structures shall contain (in either order) the members quot (the quotient) and rem (the remainder), each of which has the same type as the arguments numer and denom.

(C23 7.24.7.2 "The div, ldiv, and lldiv functions" paragraph 3.)

The imaxdiv function returns a structure of type imaxdiv_t comprising both the quotient and the remainder. The structure shall contain (in either order) the members quot (the quotient) and rem (the remainder), each of which has type intmax_t.

(C23 7.8.3.2 "The imaxdiv function" paragraph 3.)

The other definitions of structure types use the wording "at least the following members" which clearly indicates that they can contain further members. The definitions of the division types do not use such wording that clearly indicates there can be other members, but also do not clearly forbid including other members. An example of where this matters is:

#include<stdlib.h>
struct{div_t d;int x;}s={1,2,3};

If there can be other members this might be invalid or give the member x of s a value of zero. Moreover, the quot and rem members of s.d could either individually be zero or both be zero if the other members can be added between quot and rem or before both quot and rem. It seems unintended to allow definitions of the division types that contain members other than quot and rem.

Suggested correction

Modify C23 7.24.7.2 paragraph 3:

The structures shall contain exactly (in either order) the members quot (the quotient) and rem (the remainder), each of which has the same type as the arguments numer and denom.

Modify C23 7.8.3.2 paragraph 3:

The structure shall contain exactly (in either order) the members quot (the quotient) and rem (the remainder), each of which has type intmax_t.