Unknown touch device

SDL2 on Mac OS X reports “Unknown touch device” error if user touches touchpad first time.
The error hides in the following lines (SDL_cocoawindow.m:506)

Code:

    const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
    if (!SDL_GetTouch(touchId)) { // Error was set to "Unknown touch device"
        if (SDL_AddTouch(touchId, "") < 0) {
            return;
        }
    }

Seems like SDL_ClearError(); should be added after line with SDL_GetTouch.