5,361 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
2
answers
160
views
Why is the number different and the string the same?
So I have this code here
#include <stdio.h>
typedef union Converter {
char *c;
int i;
} Converter;
int main(int argc, char **argv) {
Converter f;
f.c = argv[argc - 1];
int ...
2
votes
1
answer
130
views
Accessing Union Members with Different Qualifiers in C
In the C standard (at least, I'm looking at draft C23 WG14/N3088), section 6.7.3 Type Qualifiers states:
7 If an attempt is made to modify an object defined with a const-qualified type through the ...
1
vote
4
answers
203
views
Does union "common initial sequence" include bitfields?
As far as I understand, you are allowed to access inactive members of a union, if they share a "common initial sequence" with an active one. This can be used to tag active member with a type ...
2
votes
2
answers
136
views
Pros and cons of `INSERT INTO` versus `UNION ALL`
I am working with an Oracle database in which each year's data is stored in different tables. I am not the DBA so I cannot change that. Also, I do not have the permission to consult execution plans or ...
0
votes
1
answer
113
views
Combine multiple selects and write to 1 row in a temp table
I have a stored procedure in Microsoft SQL Server. I want to combine multiple results into 1 row like this:
ID
Period
Income
202501_a
202501
50528.55
NOT LIKE THIS
ID
Period
Income
202501_a
NULL
NULL
...
5
votes
1
answer
256
views
Does accessing the inactive union member result in UB in this date union?
C++ 20 draft says (draft N4950; §11.4.1 (26)):
In a standard-layout union with an active member (11.5) of struct type T1, it is permitted to read a non-static data member m of another union member of ...
21
votes
1
answer
668
views
Default equality operator for an empty union
C++ allows us to make union class type without any data members. (cppreference even contain an example with it.)
Can one request the compiler to provide default implementation of equality comparison ...
1
vote
1
answer
168
views
Odin union question mark (.?) operator
There are a couple of places in Odin language overview where I came across .? operator for unions
It looks like this:
// - Example 1
v: union{int, f64}
i: int
i = v.? or_else 123
// - Example 2
halve ...
1
vote
1
answer
79
views
SQL - Adding Union All on derived table subquery fetches all rows
Attempting to optimize a portion of a query that is joining two related tables, and getting odd results compared to other queries in the project with similar structures. Here is a very simplified ...
0
votes
1
answer
134
views
MS Access VBA open a record set using a union query in which each query in the union reference two form date fields: FromDt and ToDt [duplicate]
When creating a recordset I get this error => 3061 To Few parameters, expected 2. How can I resolve this error?
I have a union query and it runs fine:
SELECT * FROM q_trip_usa
UNION
SELECT * FROM ...
0
votes
1
answer
164
views
Transparent replacement disabled by intervening object creation: unions broken?
Please note that this is a language-lawyer tagged question, which means it’s about the rules and wording of the C++ standard rather than practical, real-world use cases (I am aware of the advantages ...
0
votes
1
answer
123
views
Query with WHERE clause on a UNION query results in a table scan without using the indexes
An MS Access query with a WHERE clause on a UNION query results in a table scan without using the indexes.
Example: There is a table like this:
CREATE TABLE tblFigures
(
EntryDate DATETIME,
...
5
votes
3
answers
234
views
Is it allowed to use unions to modify parts of an object?
According to GCC's documentation and the various answers I read on Stack Overflow, it is allowed to use unions for type punning in C, like:
union a_union {
int i;
double d;
};
int f() {
union ...
1
vote
0
answers
118
views
How to Portably Use std::atomic Inside a Union Across Platforms (MSVC/Clang on Windows/macOS/Linux)?
I'm working on a cross-platform data structure and trying to define a compact union-based layout that allows atomic access to a 64-bit word, while also optionally accessing the lower 32-bit fields.
I ...
1
vote
2
answers
144
views
Union changing values
I am having this following little program and I am wondering why I am getting two different outputs.
#include<stdio.h>
int main() {
union ExampleUnion {
int intValue;
float ...