Bug 29350 - pthread program compiled without -lpthread crashes.
Summary: pthread program compiled without -lpthread crashes.
Status: RESOLVED DUPLICATE of bug 4372
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-04 21:29 UTC by Adam Buchbinder
Modified: 2006-10-04 21:39 UTC (History)
6 users (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Buchbinder 2006-10-04 21:29:23 UTC
Compile:

#include <pthread.h>
// #include <iostream>
int main() {
   pthread_mutexattr_t *attr;
   pthread_mutexattr_init(attr);
   return 0;
}

You get a link error.

Compile:

#include <pthread.h>
#include <iostream>
int main() {
   pthread_mutexattr_t *attr;
   pthread_mutexattr_init(attr);
   return 0;
}

It compiles with no warnings (g++ -Wall testcase.cpp), but when executed, segfaults. Compiling with -lpthread fixes it, of course, but should this be a link-time error rather than a runtime error?

This bug was originally reported in Ubuntu's Malone bugtracker:

https://launchpad.net/distros/ubuntu/+source/gcc-4.0/+bug/26663
Comment 1 Andrew Pinski 2006-10-04 21:39:19 UTC

*** This bug has been marked as a duplicate of 4372 ***