Bug 1455826

Summary: jasper broken with default standards c++ after security update
Product: [Fedora] Fedora Reporter: Josef Ridky <jridky>
Component: jasperAssignee: Josef Ridky <jridky>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: 25CC: ccheney, desktop-qa-list, jridky, thoger, tpelka
Target Milestone: ---Keywords: Patch, Regression
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1455287 Environment:
Last Closed: 2017-05-26 11:46:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1455287    
Bug Blocks:    

Description Josef Ridky 2017-05-26 08:40:55 UTC
Jasper worked fine with 0:1.900.1-16.el6_6.3 but no longer works after update to 0:1.900.1-21.el6_9

--

Simple reproducer

#include <iostream>
#include <jasper/jasper.h>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

# g++ test.cpp
In file included from /usr/include/jasper/jasper.h:77,
                 from test.cpp:2:
/usr/include/jasper/jas_math.h: In function ‘bool jas_safe_size_mul(size_t, size_t, size_t*)’:
/usr/include/jasper/jas_math.h:143: error: ‘SIZE_MAX’ was not declared in this scope
/usr/include/jasper/jas_math.h: In function ‘bool jas_safe_size_add(size_t, size_t, size_t*)’:
/usr/include/jasper/jas_math.h:170: error: ‘SIZE_MAX’ was not declared in this scope

--- Additional comment from Josef Ridky on 2017-05-25 02:46:10 EDT ---

Problem is in stdint.h header file due this statement:

/* The ISO C99 standard specifies that in C++ implementations these
   macros should only be defined if explicitly requested.  */
#if !defined __cplusplus || defined __STDC_LIMIT_MACROS

Compiling with g++ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS foo.cpp will fix this issue.

--- Additional comment from Tomas Hoger on 2017-05-25 06:13:14 EDT ---

Would we fix this by:

#ifndef SIZE_MAX
#define SIZE_MAX ((size_t) - 1)
#endif

added to jas_math.h after:

#include <stdint.h>

possibly inside of:

#ifdef __cplusplus

?

Comment 1 Josef Ridky 2017-05-26 11:46:39 UTC
This issue is not presented in Fedora distribution.

Comment 2 Tomas Hoger 2017-05-26 12:42:38 UTC
It seems the above workaround should not be needed when using glibc 2.18 and later:

https://sourceware.org/bugzilla/show_bug.cgi?id=15366
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=1ef74943ce2f114c78b215af57c2ccc72ccdb0b7