** Attachment added: "rng.cpp"
   
https://bugs.launchpad.net/ubuntu/+source/gcc-4.7/+bug/1153768/+attachment/3568874/+files/rng.cpp

** Description changed:

  g++ crashes when compiling C++11 code. I believe the error in particular
  has to with the features from the <future> and <thread> headers, i.e.
  package_tasks and futures. The code in particular that  crashed g++ was
  when I had a type mismatch in the packaged_task<T> template parameter.
  Rather than warning of a type mismatch g++ crashes.
  
- The particular code is the following (I do not include the prototyped 
functions here but they have no errors): 
+ The particular code is the following (I do not include the prototyped 
functions here but they have no errors):
  Note the type mismatch between the packaged_task and simulate2(void);
- #include <random>
- #include <iostream>
- #include <chrono>
- #include <thread>
- #include <future>
- 
- using namespace std;
- 
- static int threads = 10;
- static int runs = 1000000; //1 000 000
- double f(double);
- double simulate(double,double,int);
- double simulate2(void);
- 
- int main(void){
-         packaged_task<double(double,double,int)> simulations[threads];
-         future<double> results[threads];
-         chrono::high_resolution_clock::time_point lStart = 
chrono::high_resolution_clock::now();
-         for(int i = 0; i < threads; i++){
-                 simulations[i] = packaged_task<double(double,double,int)> 
(&simulate2); //Type Mismatch 
-                 /*Expected double(double,double,int) but actual type is 
double(void)*/
-                 results[i] = simulations[i].get_future();
-                 thread(std::move(simulations[i]), 0, 4, 
runs/threads).detach();//100 000 000 * 10
-         }
-         double sum = 0;
-         for(future<double>& task : results){
-                 sum += task.get();
-         }
-         cout << "Threaded: " << sum/(double)threads << endl;
-         chrono::high_resolution_clock::time_point lEnd = 
chrono::high_resolution_clock::now();
-         cout << "Time: " <<  chrono::duration_cast<chrono::milliseconds>(lEnd 
- lStart).count() << endl;
-         lStart = chrono::high_resolution_clock::now();
-         cout << "Single:" << simulate(0, 4, runs)  << endl; //1 000 000 000 
Single Thread
-         lEnd = chrono::high_resolution_clock::now();
-         cout << "Time: " <<  chrono::duration_cast<chrono::milliseconds>(lEnd 
- lStart).count() << endl;
-         return 0;
- }
  
  ProblemType: Crash
  DistroRelease: Ubuntu 13.04
  Package: g++-4.7 4.7.2-22ubuntu3
  ProcVersionSignature: Ubuntu 3.8.0-11.20-generic 3.8.2
  Uname: Linux 3.8.0-11-generic x86_64
  ApportVersion: 2.9.1-0ubuntu1
  Architecture: amd64
  Date: Mon Mar 11 15:13:39 2013
  ExecutablePath: /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus
  MarkForUpload: True
  SourcePackage: gcc-4.7
  UpgradeStatus: No upgrade log present (probably fresh install)

** Description changed:

  g++ crashes when compiling C++11 code. I believe the error in particular
  has to with the features from the <future> and <thread> headers, i.e.
  package_tasks and futures. The code in particular that  crashed g++ was
  when I had a type mismatch in the packaged_task<T> template parameter.
  Rather than warning of a type mismatch g++ crashes.
  
- The particular code is the following (I do not include the prototyped 
functions here but they have no errors):
+ The particular code attached as rng.cpp
  Note the type mismatch between the packaged_task and simulate2(void);
  
  ProblemType: Crash
  DistroRelease: Ubuntu 13.04
  Package: g++-4.7 4.7.2-22ubuntu3
  ProcVersionSignature: Ubuntu 3.8.0-11.20-generic 3.8.2
  Uname: Linux 3.8.0-11-generic x86_64
  ApportVersion: 2.9.1-0ubuntu1
  Architecture: amd64
  Date: Mon Mar 11 15:13:39 2013
  ExecutablePath: /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus
  MarkForUpload: True
  SourcePackage: gcc-4.7
  UpgradeStatus: No upgrade log present (probably fresh install)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1153768

Title:
  Crash on compiling c++11 code with <future> and <thread>

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.7/+bug/1153768/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to