Strange error when compiling

I have a strange error, when I compile some codes in my project.
I try to make a menusystem to a TFT-shield and use
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>

The errormessage is:
C:\Arduino\Project\Menu_MCU\Menu_MCU1\f_Submenu2.ino: In function ‘DrawMenu22’:
C:\Arduino\Project\Menu_MCU\Menu_MCU1\f_Submenu2.ino:50:1: internal compiler error: Segmentation fault


Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
lto-wrapper.exe: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.
c:/program files (x86)/arduino/hardware/tools/avr/bin/…/lib/gcc/avr/5.4.0/…/…/…/…/avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status

void DrawMenu22() 
{   //KALIBRERING af mm/m2
  page = 22;
/ Title = "KALIB. af mm/m2";
  btn_111.initButton(&tft, 120, 230, 220, 40, WHITE, BLUE, WHITE, "OK", 2);
  btn_112.initButton(&tft, 120, 280, 220, 40, WHITE, RED, WHITE, "Tilbage", 2);
  drawString(8, 310, "DrawMenu22. KALIBRERING af mm/m2", WHITE, 1);
}  //Line 50

But the error is for mee to see caused from a later subroutine

void RefreshInterval()
  tft.fillRect(40, 134, 180, 24, BLACK);
  tft.setCursor(100, 135); 
  if(interval == 10)  { tft.setCursor (85, 135); };

for if I change
tft.setCursor(100, 135);
tft.setCursor(52, 135);
the error disappear.
It is not exactly ‘52’, some other numbers also compile without errors.

Somebody knowing where I can try to find the error?

This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:

Here's the traditional workaround:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

Due to a bug, this workaround doesn't work with Arduino IDE 1.8.6, but it will work with any other version of the Arduino IDE.

If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.

Alternate workaround:
One of the Arduino developers recently worked on this and claims to have fixed it. There is a special beta testing hardware package you can install via the Arduino IDE's Boards Manager that has the fix:

  • (In the Arduino IDE) File > Preferences
  • In the "Additional Boards Manager URLs" field, enter: If you already have an additional Boards Manager URL in that field, you can separate multiple URLs with commas or click the button on the right side of the field to open a dialog that allows you to add each on its own line.
  • Click "OK"
  • Tools > Board > Boards Manager
  • Wait for the downloads to finish
  • Click on "Arduino AVR Boards by Arduino"
  • Click the "Update" button.
  • Wait for the update to finish.
  • Click "Close".

Thank you for your answer.
I read IDE 1.8.6 - SD-Lib "Datalogger" - segmentation fault · Issue #7949 · arduino/Arduino · GitHub, and I think, that I return to the old version 1.8.5. it is the easy way for mee.
If it don't help, I will try you explanation.