Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Resource union throws access violation for Fonts.  (Read 1858 times)

0 Members and 1 Guest are viewing this topic.

R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
[SOLVED] Resource union throws access violation for Fonts.
« on: July 02, 2016, 01:10:26 am »
    So I am trying to write a Resource loader and manager (Yes I know of Thor, this is just a "learning" project.) and I have started experimenting with unions, not something I use very often. I created a class (as seen in code below) called resource which has a union that contains a texture/font. The texture loads correctly; however the font throws an access violation

Exception thrown at 0x00C5DBE0 in Project.exe: 0xC0000005: Access violation reading location 0x00000004.

The following is my complete and minimal example.
(click to show/hide)
« Last Edit: July 02, 2016, 02:19:11 am by R23MJ »

R23MJ

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Resource union throws access violation for Fonts.
« Reply #1 on: July 02, 2016, 02:18:57 am »
Evan, over at StackOverflow informed me that only the first element in a union is default constructed. This helped me solve the problem by assuring which ever item I plan to use in constructed properly before I use it.