c++0x: error: ‘sleep_for’ is not a member of ‘std::this_thread’

Bug #608145 reported by Matej Kenda
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gcc-4.4 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: gcc-4.4

The following code doesn't compile out of the box with g++ 4.4 on Lucid.

---

#include <thread>

int main(int argc, const char* argv[])
{
            std::this_thread::sleep_for(std::chrono::seconds(1));
}

---

$ g++ sleep_for.cpp -o sleep_for -std=c++0x
sleep_for.cpp: In function ‘int main(int, const char**)’:
sleep_for.cpp:5: error: ‘sleep_for’ is not a member of ‘std::this_thread’

If compiled with an additional define _GLIBCXX_USE_NANOSLEEP, then it compiles and works fine.

$ g++ sleep_for.cpp -o sleep_for -std=c++0x -D_GLIBCXX_USE_NANOSLEEP

The define _GLIBCXX_USE_NANOSLEEP is set from the gcc configuration scripts and is based on whether nanosleep is supported on the target platform.

This is the case for Ubuntu Lucid, where nanosleep is available.
---
Architecture: amd64
DistroRelease: Ubuntu 10.04
NonfreeKernelModules: binfmt_misc snd_hda_codec_atihdmi snd_hda_codec_analog tpm_infineon arc4 snd_hda_intel iwlagn snd_hda_codec snd_pcm_oss snd_hwdep snd_mixer_oss snd_seq_dummy snd_pcm snd_seq_oss snd_seq_midi iwlcore snd_rawmidi pcmcia uinput radeon snd_seq_midi_event joydev snd_seq snd_timer snd_seq_device ttm hp_accel mac80211 uvcvideo lis3lv02d drm_kms_helper sdhci_pci videodev coretemp video sdhci input_polldev snd tpm_tis yenta_socket psmouse v4l1_compat tpm drm ppdev rsrc_nonstatic v4l2_compat_ioctl32 tpm_bios output led_class soundcore i2c_algo_bit serio_raw pcmcia_core hp_wmi cfg80211 parport_pc snd_page_alloc intel_agp lp parport usbhid hid ohci1394 ieee1394 e1000e ahci
Package: gcc-4.4 4.4.3-4ubuntu5
PackageArchitecture: amd64
ProcEnviron:
 LANGUAGE=en_GB:en
 PATH=(custom, user)
 LANG=en_GB.utf8
 SHELL=/bin/bash
Tags: lucid
Uname: Linux 2.6.34-020634-generic x86_64
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare vboxusers

Revision history for this message
Matej Kenda (matejken) wrote : Dependencies.txt

apport information

tags: added: apport-collected
description: updated
Revision history for this message
Eliah Kagan (degeneracypressure) wrote :

I can reproduce this bug on Maverick (x86_64). However, it does not occur on my 32-bit Natty system, which uses gcc-4.5 (instead of gcc-4.4).

Here are details for the Maverick system:

ek@Apok:~$ uname -a
Linux Apok 2.6.35-22-generic #35-Ubuntu SMP Sat Oct 16 20:45:36 UTC 2010 x86_64 GNU/Linux

ek@Apok:~$ apt-cache policy gcc g++
gcc:
  Installed: 4:4.4.4-1ubuntu2
  Candidate: 4:4.4.4-1ubuntu2
  Version table:
 *** 4:4.4.4-1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status
g++:
  Installed: 4:4.4.4-1ubuntu2
  Candidate: 4:4.4.4-1ubuntu2
  Version table:
 *** 4:4.4.4-1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status

ek@Apok:~$ apt-cache policy libstdc++ | head -n 14 # no others are installed
libstdc++6:
  Installed: 4.5.1-7ubuntu2
  Candidate: 4.5.1-7ubuntu2
  Version table:
 *** 4.5.1-7ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status
libstdc++6-4.4-dev:
  Installed: 4.4.4-14ubuntu5
  Candidate: 4.4.4-14ubuntu5
  Version table:
 *** 4.4.4-14ubuntu5 0
        500 http://us.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Eliah Kagan (degeneracypressure) wrote :

I am also able to reproduce it on a 32-bit Maverick system (still gcc-4.4).

ek@Kip:~/source$ uname -a
Linux Kip 2.6.35-23-generic #40-Ubuntu SMP Wed Nov 17 22:15:35 UTC 2010 i686 GNU/Linux

(Same libstdc++ packages as above, just i386 instead of x86_64.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.