The function pthread_attr_init() must be called to initialize the attribute structure before using it:
... pthread_attr_t attr; ... pthread_attr_init (&attr);
You could call pthread_attr_destroy() to "uninitialize" the thread attribute structure, but almost no one ever does (unless you have POSIX-compliant code).
In the descriptions that follow, I've marked the default values with "(default)."