Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
darktable main repository
C C++ CMake Objective-C JavaScript Shell Other

Fix handling of integer preference parameters

Before this commit, the code did:
    int max = G_MAXINT; /* INT_MAX, 2147483647 */
    float factor = 1.0f;
    max *= factor;

Dimitry Andric helped me understand the problem; here is the
    Here, "max * factor" is 2147483648.0, not 2147483647.0: the value is
    rounded up because the float type has a mantissa of 23 bits only.
    However, converting 2147483648.0 to an integer is an undefined

The resulting value depends on the compiler and the level of

    GCC (all versions) with -O0: max = -2147483648
    GCC (all versions) with -O2: max =  2147483647

    Clang up-to 3.5 with -O0:    max = -2147483648
    Clang up-to 3.5 with -O2:    max =  2147483647
    (ie. same behaviour as GCC)

    Clang 3.6+ with -O0:         max = -2147483648
    Clang 3.6+ with -O2:         max =           0

In the context of the preferences dialog, this means that all integers
must be between min=0 and max=0.

The fix, suggested by Dimitry, is to use a double as an intermediate
variable: it is wide enough to store "max * factor" without rounding up
the value. Then, 2147483647.0 can be converted to 2147483647.
latest commit 9d77a28e54
@dumbbell dumbbell authored


darktable is an open source photography workflow application and RAW developer. A virtual lighttable and darkroom for photographers. It manages your digital negatives in a database, lets you view them through a zoomable lighttable and enables you to develop raw images and enhance them.



Release build

./ --prefix /opt/darktable --buildtype Release

Debug build

./ --prefix /opt/darktable --buildtype Debug

Tip: Check that you have the latest gphoto2 library installed in order to support the newest cameras.

Issue tracking


Mailing lists

Something went wrong with that request. Please try again.