From 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 Aug 2025 22:58:58 -0500 Subject: removing all downloaded devdocs files --- devdocs/gcc~13/cast-to-union.html | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 devdocs/gcc~13/cast-to-union.html (limited to 'devdocs/gcc~13/cast-to-union.html') diff --git a/devdocs/gcc~13/cast-to-union.html b/devdocs/gcc~13/cast-to-union.html deleted file mode 100644 index db9be2ba..00000000 --- a/devdocs/gcc~13/cast-to-union.html +++ /dev/null @@ -1,23 +0,0 @@ -

6.31 Cast to a Union Type

A cast to a union type is a C extension not available in C++. It looks just like ordinary casts with the constraint that the type specified is a union type. You can specify the type either with the union keyword or with a typedef name that refers to a union. The result of a cast to a union is a temporary rvalue of the union type with a member whose type matches that of the operand initialized to the value of the operand. The effect of a cast to a union is similar to a compound literal except that it yields an rvalue like standard casts do. See Compound Literals.

Expressions that may be cast to the union type are those whose type matches at least one of the members of the union. Thus, given the following union and variables:

union foo { int i; double d; };
-int x;
-double y;
-union foo z;
-

both x and y can be cast to type union foo and the following assignments

-
z = (union foo) x;
-z = (union foo) y;
-

are shorthand equivalents of these

-
z = (union foo) { .i = x };
-z = (union foo) { .d = y };
-

However, (union foo) FLT_MAX; is not a valid cast because the union has no member of type float.

Using the cast as the right-hand side of an assignment to a variable of union type is equivalent to storing in a member of the union with the same type

union foo u;
-/*  */
-u = (union foo) x  ≡  u.i = x
-u = (union foo) y  ≡  u.d = y
-

You can also use the union cast as a function argument:

void hack (union foo);
-/*  */
-hack ((union foo) x);
-
-

- © Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
- https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Cast-to-Union.html -

-
-- cgit v1.2.3