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)


    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) {

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