View Issue Details

IDProjectCategoryView StatusLast Update
0000769OpenMPTlibopenmptpublic2016-04-26 17:08
Reportersraue Assigned Tomanx  
Status resolvedResolutionfixed 
Product VersionOpenMPT / libopenmpt 0.2-beta16 (upgrade first) 
Fixed in VersionOpenMPT / libopenmpt 0.2-beta17 (upgrade first) 
Summary0000769: libopenmpt fails to build with gcc-6

libopenmpt-0.2.5787-beta16 fails to build with gcc-6 (RC)

Steps To Reproduce

compile libopenmpt with gcc-6

Additional Information

Generic.x86_64-8.0-devel/libopenmpt-0.2.5787-beta16/libopenmpt/libopenmpt_ext.cpp -o libopenmpt/libopenmpt_la-libopenmpt_ext.o
/home/stephan/projects/openelec-7.91.git/build.OpenELEC-Generic.x86_64-8.0-devel/libopenmpt-0.2.5787-beta16/soundlib/tuning.cpp: In member function 'OpenMPT::CTuningBase::NOTEINDEXTYPE OpenMPT::CTuningRTI::GetRefNote(OpenMPT::CTuningBase::NOTEINDEXTYPE) const':
/home/stephan/projects/openelec-7.91.git/build.OpenELEC-Generic.x86_64-8.0-devel/libopenmpt-0.2.5787-beta16/soundlib/tuning.cpp:380:43: error: invalid operands of types 'gnu_cxx::__enable_if<true, double>::type {aka double}' and 'OpenMPT::CTuningBase::UNOTEINDEXTYPE {aka short unsigned int}' to binary 'operator%'
else return (GetGroupSize() - (abs(note) % GetGroupSize())) % GetGroupSize();

Makefile:2756: recipe for target 'soundlib/libopenmpt_la-tuning.lo' failed
make[1]: *** [soundlib/libopenmpt_la-tuning.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
mv -f libopenmpt/.deps/libopenmpt_la-libopenmpt_ext.Tpo libopenmpt/.deps/libopenmpt_la-libopenmpt_ext.Plo
mv -f libopenmpt/.deps/libopenmpt_la-libopenmpt_impl.Tpo libopenmpt/.deps/libopenmpt_la-libopenmpt_impl.Plo
mv -f src/openmpt123/.deps/openmpt123-openmpt123.Tpo src/openmpt123/.deps/openmpt123-openmpt123.Po
make[1]: Leaving directory '/home/stephan/projects/openelec-7.91.git/build.OpenELEC-Generic.x86_64-8.0-devel/libopenmpt-0.2.5787-beta16/.x86_64-openelec-linux-gnu'
Makefile:1178: recipe for target 'all' failed
make: *** [all] Error 2
TagsNo tags attached.
Has the bug occurred in previous versions?
Tested code revision (in case you know it)


Saga Musix

Saga Musix

2016-04-26 10:20

administrator   ~0002346

Seems like it must be a bug in this RC, you can easily see that both operands are int16 and uint16, certainly not double?



2016-04-26 14:17

administrator   ~0002349

From a first glance, this looks like a GCC6 bug to me. I have to do further investigation here though.
I worked around the problem in r6295.



2016-04-26 14:17


bug-769-fix-v1.patch (610 bytes)   
Index: soundlib/tuning.cpp
--- soundlib/tuning.cpp	(revision 6294)
+++ soundlib/tuning.cpp	(working copy)
@@ -375,7 +375,8 @@
 	if(!IsOfType(TT_GROUPGEOMETRIC)) return 0;
 	if(note >= 0) return note % GetGroupSize();
-	else return (GetGroupSize() -  (abs(note) % GetGroupSize())) % GetGroupSize();
+	// static_cast<int>(note) because g++-6 template-disables std::abs overloads for 8bit and 16bit integer types via std::enable_if.
+	else return (GetGroupSize() - (std::abs(static_cast<int>(note)) % GetGroupSize())) % GetGroupSize();
bug-769-fix-v1.patch (610 bytes)   


2016-04-26 14:23

administrator   ~0002350;type=bug will also apply to 0.2.5787-beta16, if you prefer to stay on -beta16.



2016-04-26 16:57

administrator   ~0002353

Last edited: 2016-04-26 17:08

View 2 revisions

So, I'm still not sure whether this is a GCC 6 problem or in fact a language specification problem.

Quoting the relevant sections: P.1080 § 26.9.10 "If abs() is called with an argument of type X for which is_unsigned<X>::value is true and if X cannot be converted to int by integral promotion (4.5), the program is ill-formed. [ Note: Arguments that can be promoted to int are permitted for compatibility with C. — end note ]" P.1083 § "Otherwise, if any argument of arithmetic type corresponding to a double parameter has type double or an integer type, then all arguments of arithmetic type corresponding to double parameters are effectively cast to double."

In any case, the work-around is correct and will work for all old and new compilers.

Issue History

Date Modified Username Field Change
2016-04-26 09:58 sraue New Issue
2016-04-26 10:20 Saga Musix Note Added: 0002346
2016-04-26 10:43 manx Assigned To => manx
2016-04-26 10:43 manx Status new => assigned
2016-04-26 13:53 manx Status assigned => confirmed
2016-04-26 14:17 manx Note Added: 0002349
2016-04-26 14:17 manx File Added: bug-769-fix-v1.patch
2016-04-26 14:23 manx Note Added: 0002350
2016-04-26 16:57 manx Note Added: 0002353
2016-04-26 16:57 manx Status confirmed => resolved
2016-04-26 16:57 manx Fixed in Version => OpenMPT / libopenmpt 0.2-beta17 (upgrade first)
2016-04-26 16:57 manx Resolution open => fixed
2016-04-26 17:08 manx Note Edited: 0002353 View Revisions