**Document: **N1409

**Date: **2009/09/29

## Defect Report #nnn

Previous Defect Report < - > Next Defect Report

**Submitter:** Richard Hansen (BBN Technologies)

**Submission Date:** 2007-08-04

**Source:** Randy Meyers<USA>

**Reference Document:** N/A

**Version:**

**Date:** 2007-08-04

**Subject:** aliasing and effective type as it applies to unions/aggregates

**Summary**

My question concerns the phrasing of bullet 5 of 6.5p7
(aliasing as it applies to unions/aggregates).
Unless my understanding of effective type is incorrect, it seems
like the union/aggregate condition should apply to the effective type,
not the lvalue type.

Here are some more details:

Take the following code snippet as an example:

```
union {int a; double b;} u;
```

u.a = 5;

From my understanding of the definition of effective type (6.5p6),
the effective type of the object at location &u is
`union {int a; double b;}`

. The type of the lvalue
expression that is accessing the object at &u (in the
second line) is `int`

.

From my understanding of the definition of compatible type (6.2.7),
`int`

is not compatible with `union {int a; double b;}`

,
so bullets 1 and 2 of 6.5p7 do not apply. int is not the signed or unsigned
type of the union type, so bullets 3 and 4 do not apply.
`int`

is not a character type, so bullet 6 does not apply.

That leaves bullet 5. However, int is not an aggregate or union type,
so that bullet also does not apply. That means that the above code
violates the aliasing rule, which it obviously should not.

I believe that bullet 5 should be rephrased to indicate that if
the *effective type* (not the lvalue type) is an aggregate
or union type that contains a member with type compatible with the
lvalue type, then the object may be accessed.

**Suggested Technical Corrigendum**

Here is a possible rewrite of 6.5p7:

An object with effective type Q shall have its stored value accessed only by an lvalue expression of type T when one of the following applies:

- T is compatible with Q,
- T is a qualified version of a type compatible with Q,
- T is the signed or unsigned type corresponding to Q,
- T is the signed or unsigned type corresponding to a qualified version of Q,
- T is a character type, or
- Q is an aggregate or union type that includes a member of type R that satisfies one of these conditions (substituting R for Q, recursively if necessary).

**Committee Discussion**

Previous Defect Report < - >
Next Defect Report

--------------030608090503060701010402--