Jump to content

Talk:Union type: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
GreenC bot (talk | contribs)
Add {{reflist-talk}} to #Misconception (via reftalk bot)
Line 10: Line 10:


{{reflist-talk}}
{{reflist-talk}}

== At most one member of a union can be active at any time ==

The section about C/C++ states: ''"The primary use of a union is allowing access to a common location by different data types, for example hardware input/output access, bitfield and word sharing, or type punning."'' This usage might be common but is not actually guaranteed to work according to the standard. I think it should at least be mentioned that this is either undefined behaviour or relying on extra guarantees given by the compiler. [[Special:Contributions/90.230.55.237|90.230.55.237]] ([[User talk:90.230.55.237|talk]]) 09:35, 25 November 2019 (UTC)

Revision as of 09:35, 25 November 2019

WikiProject iconComputer science C‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

WikiProject iconComputing: Software C‑class Low‑importance
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software (assessed as Mid-importance).

Template:IEP assignment

union

This article seems to suggest that it is possible to have methods, static members, private and protected methods, and probably a few other things that I am forgetting, In C++ unions. As far as I know this is not the case, but I am not 100% certain of this. Can someone clarify in the article what features of structs are not possible for unions in C++.--King Mir 18:31, 29 April 2007 (UTC)[reply]

Misconception

When you talk about union types, the first thing that pops up is the unions from C/C++, but there is such thing in the type theory of programming languages. Don't have any paper on hand, but the Types and Programming Languages by B. Pierce describes the intuitions, which is much general that it is in the current page [1] — Preceding unsigned comment added by Hfehrmann (talkcontribs) 23:15, 19 December 2016 (UTC)[reply]

References

At most one member of a union can be active at any time

The section about C/C++ states: "The primary use of a union is allowing access to a common location by different data types, for example hardware input/output access, bitfield and word sharing, or type punning." This usage might be common but is not actually guaranteed to work according to the standard. I think it should at least be mentioned that this is either undefined behaviour or relying on extra guarantees given by the compiler. 90.230.55.237 (talk) 09:35, 25 November 2019 (UTC)[reply]