From ab75b8bfe67b05ae616ebeb97f9fe9c361569c63 Mon Sep 17 00:00:00 2001
From: John <johnz@posteo.net>
Date: Thu, 30 Aug 2018 23:55:19 +0200
Subject: [PATCH] telegram-desktop: add patch for gcc-8.2.0

this also fixes cross compilation
---
 ...61d09c9193386a32f70821ff841819c88379.patch | 27 +++++++++++++++++++
 srcpkgs/telegram-desktop/template             |  3 +--
 2 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/telegram-desktop/patches/dc1e61d09c9193386a32f70821ff841819c88379.patch

diff --git a/srcpkgs/telegram-desktop/patches/dc1e61d09c9193386a32f70821ff841819c88379.patch b/srcpkgs/telegram-desktop/patches/dc1e61d09c9193386a32f70821ff841819c88379.patch
new file mode 100644
index 0000000000..ed869e2a1b
--- /dev/null
+++ b/srcpkgs/telegram-desktop/patches/dc1e61d09c9193386a32f70821ff841819c88379.patch
@@ -0,0 +1,27 @@
+From dc1e61d09c9193386a32f70821ff841819c88379 Mon Sep 17 00:00:00 2001
+From: Nicholas Guriev <guriev-ns@ya.ru>
+Date: Fri, 31 Aug 2018 00:28:27 +0300
+Subject: [PATCH] Workaround internal compiler error in GCC
+
+Fixes: #5111
+---
+ Telegram/SourceFiles/apiwrap.cpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp
+index 3301b6f04..286d2b55c 100644
+--- Telegram/SourceFiles/apiwrap.cpp
++++ Telegram/SourceFiles/apiwrap.cpp
+@@ -2390,7 +2390,11 @@ void ApiWrap::requestFileReference(
+ 
+ 	request(std::move(data)).done([=](const auto &result) {
+ 		const auto parsed = Data::GetFileReferences(result);
+-		for (const auto &[origin, reference] : parsed) {
++		for (const auto &p : parsed) {
++			// Unpack here the parsed pair by hand to workaround a GCC bug.
++			// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87122
++			const FileLocationId &origin = p.first;
++			const QByteArray &reference = p.second;
+ 			const auto documentId = base::get_if<DocumentFileLocationId>(
+ 				&origin);
+ 			if (documentId) {
diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 09d870fb4c..226a539ba0 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=1.3.14
-revision=1
+revision=2
 _libtgvoip_commit=bfa1e6ab76a467c6c6bff7eabb7c213acc7a1b34
 _GSL_commit=d846fe50a3f0bb7767c7e087a05f4be95f4da0ec
 _variant_commit=550ac2f159ca883d360c196149b466955c77a573
@@ -37,7 +37,6 @@ checksum="83daeded641f79bd370b5e83be88242ab57520e7754f1371a9e5c1f3d9863f2a
  d24e6d9df2b8aa5739d3b9077c6b0ff0ef4d5ef8acc52c3a57e32893854d8d18"
 
 build_options=clang
-build_options_default=clang
 
 if [ "$build_option_clang" ]; then
 	CFLAGS="-fPIE -fPIC -fstack-protector-strong"