Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 552370 - media-libs/devil-1.7.8-r2: build failure with gcc-5.1 due to use of "restrict" keyword in C++ code
Summary: media-libs/devil-1.7.8-r2: build failure with gcc-5.1 due to use of "restrict...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Games
Depends on:
Blocks: gcc-5
  Show dependency tree
Reported: 2015-06-17 08:55 UTC by Jasen Borisov
Modified: 2015-09-03 15:17 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---

build.log (build.log,26.54 KB, text/plain)
2015-06-21 08:05 UTC, Jasen Borisov
emerge --info output (emerge_info.txt,17.83 KB, text/plain)
2015-06-21 08:07 UTC, Jasen Borisov
Fix usage of restrict keyword (devil-1.7.8-fix_restrict_keyword_usage.patch,503 bytes, patch)
2015-09-03 14:24 UTC, Sven Eden
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jasen Borisov 2015-06-17 08:55:09 UTC
Emerging media-libs/devil-1.7.8-r2 fails with a compile error from gcc:

In file included from ./../src-IL/src/il_exr.cpp:14:0:
./../src-IL/include/il_internal.h:230:54: error: expected ‘,’ or ‘...’ before ‘FileName’
 ILboolean ilIsValidBmp(ILconst_string CONST_RESTRICT FileName);

Reproducible: Always

build log:

emerge -pqv '=media-libs/devil-1.7.8-r2::gentoo':

[ebuild  N    ] media-libs/devil-1.7.8-r2  USE="X gif jpeg jpeg2k mng opengl png sdl tiff xpm -allegro -glut -nvtt -openexr -static-libs" CPU_FLAGS_X86="sse sse2 -sse3"

emerge --info '=media-libs/devil-1.7.8-r2::gentoo':
Comment 1 Mike Gilbert gentoo-dev 2015-06-20 22:21:31 UTC
Attach your build log to the bug; patebins are not acceptable.
Comment 2 Jasen Borisov 2015-06-21 08:05:43 UTC
Created attachment 405456 [details]
Comment 3 Jasen Borisov 2015-06-21 08:07:00 UTC
Created attachment 405458 [details]
emerge --info output
Comment 4 Jasen Borisov 2015-06-21 08:08:27 UTC
Done, attached both the build.log and the emerge --info output.

Sorry for using a pastebin at first. This was my first time reporting a bug on the gentoo bugzilla. I didn't know.
Comment 5 SpanKY gentoo-dev 2015-06-24 14:52:56 UTC
i'd guess a bug in devil.  the error message indicates CONST_RESTIRCT isn't being defined and that's something devil itself sets up.
Comment 6 Mr. Bones. (RETIRED) gentoo-dev 2015-06-25 03:36:51 UTC
I was hoping for some direction about the change in behavior between gcc4 and gcc5 since devil builds fine with current stable gcc4.

The line that's erroring is:

ILboolean ilIsValidBmp(ILconst_string CONST_RESTRICT FileName);

and CONST_RESTRICT is defined as const restrict
and ILconst_string is defined as wchar_t const *
so...  doesn't like wchar_t const * const restrict FileName now?
Comment 7 SpanKY gentoo-dev 2015-07-06 09:18:31 UTC
(In reply to Mr. Bones. from comment #6)

then you want the gcc-porting@ alias ;)

the problem is that the devil configure script tests for the "restrict" keyword using the C frontend.  in C99, this keyword was added to C.  however, C++ has no such keyword, and the header uses that single test to determine language functionality for both C and C++.

it's further complicated by the fact that gcc-5 switched from C89 as the default standard to C11 -- C89 didn't have restrict, but C99/C11 do, so the configure tests now pass.

you could hack around it by doing:
  sed -i '/RESTRICT/s:restrict:__restrict__:' include/IL/il.h

if you wanted something more complete, then maybe use "#ifdef __cplusplus" and either do:
#ifdef __cplusplus

or something like:
# ifdef __cplusplus
#  define RESTRICT restrict
# else
#  define RESTRICT __restrict__
# endif

it also looks like RESTRICT_KEYWORD is doubly defined because the autotool logic has two independent tests:

which you can see in the config.log w/gcc-5:
conftest.c:24:0: warning: "RESTRICT_KEYWORD" redefined
conftest.c:23:0: note: this is the location of the previous definition
 #define RESTRICT_KEYWORD /**/
Comment 8 Sven Eden 2015-09-03 14:24:35 UTC
Created attachment 410928 [details, diff]
Fix usage of restrict keyword

This patch fixed the issue on my machine and devil merged fine with gcc-5.2.0
Comment 9 Mr. Bones. (RETIRED) gentoo-dev 2015-09-03 15:17:15 UTC
great!  thanks for the patch.  In portage.