KKitForma.

Language

EnglishEnglishTürkçeTurkishTool unavailable · open catalogDeutschGermanTool unavailable · open catalogEspañolSpanishTool unavailable · open catalogFrançaisFrenchTool unavailable · open catalogPortuguêsPortugueseTool unavailable · open catalogItalianoItalianTool unavailable · open catalogNederlandsDutchTool unavailable · open catalogPolskiPolishTool unavailable · open catalogРусскийRussianTool unavailable · open catalogУкраїнськаUkrainianTool unavailable · open catalogSvenskaSwedishTool unavailable · open catalogNorskNorwegianTool unavailable · open catalogDanskDanishTool unavailable · open catalogSuomiFinnishTool unavailable · open catalogČeštinaCzechTool unavailable · open catalogRomânăRomanianTool unavailable · open catalogΕλληνικάGreekTool unavailable · open catalogالعربيةArabicTool unavailable · open catalogעבריתHebrewTool unavailable · open catalogفارسیPersianTool unavailable · open catalogاردوUrduTool unavailable · open catalogहिन्दीHindiTool unavailable · open catalogবাংলাBengaliTool unavailable · open catalogதமிழ்TamilTool unavailable · open catalogతెలుగుTeluguTool unavailable · open catalogमराठीMarathiTool unavailable · open catalogગુજરાતીGujaratiTool unavailable · open catalog简体中文Chinese SimplifiedTool unavailable · open catalog繁體中文Chinese TraditionalTool unavailable · open catalog日本語JapaneseTool unavailable · open catalog한국어KoreanTool unavailable · open catalogTiếng ViệtVietnameseTool unavailable · open catalogไทยThaiTool unavailable · open catalogBahasa IndonesiaIndonesianTool unavailable · open catalogBahasa MelayuMalayTool unavailable · open catalogFilipinoFilipinoTool unavailable · open catalogKiswahiliSwahiliTool unavailable · open catalogAfrikaansAfrikaansTool unavailable · open catalogMagyarHungarianTool unavailable · open catalogБългарскиBulgarianTool unavailable · open catalogHrvatskiCroatianTool unavailable · open catalogSrpskiSerbianTool unavailable · open catalogSlovenčinaSlovakTool unavailable · open catalogSlovenščinaSlovenianTool unavailable · open catalogLietuviųLithuanianTool unavailable · open catalogLatviešuLatvianTool unavailable · open catalogEestiEstonianTool unavailable · open catalogCatalàCatalanTool unavailable · open catalogEuskaraBasqueTool unavailable · open catalog
← All topics and search

C++

Object lifetimes, templates, standard library and C++ build errors.

55 troubleshooting guides · Page 2 / 3

  1. Why does deleting a derived object through its base pointer miss cleanup?

    A polymorphic base used for owning deletion needs an appropriate virtual destructor. Otherwise deleting through the base can violate the language’s destruction contract.

  2. Why does storing Derived values in vector<Base> lose derived behavior?

    A by-value Base element contains only the base subobject copied from a derived value. The derived portion is not stored invisibly alongside it.

  3. Why does my const member function fail to override the base operation?

    A small signature difference, including const qualification or ref qualification, can define another function instead of overriding the intended virtual member.

  4. Why does a virtual call in a base constructor use base behavior?

    Construction progresses through class subobjects. During base construction, virtual dispatch does not behave as though the final derived object were already fully established.

  5. Why does a virtual call use the base class default argument?

    Default arguments are selected from the statically visible declaration, while the virtual function body is dispatched dynamically. Mixing different defaults across overrides makes the call look inconsistent.

  6. Why does returning const T& to a local temporary still dangle?

    A const reference does not universally extend every temporary through every return boundary. A local result cannot be borrowed safely after its owner has ended.

  7. Why does a returned lambda read invalid local variables?

    A reference capture borrows the original local object. Returning the closure does not extend that local object’s lifetime.

  8. Why does a callback capturing this crash after its owner is destroyed?

    Capturing this preserves a pointer to the object, not ownership of it. A scheduler can retain the closure after the object’s lifetime ends.

  9. Why does if(optional<bool>) enter for a stored false?

    The optional condition tests engagement, not the truth value of the contained bool. A present false is different from no value.

  10. Why does std::get throw when my variant holds another alternative?

    get requests a particular active alternative; it is not a conversion from whichever value happens to be stored. A mismatch can produce bad_variant_access.

  11. Why does vector<int>{10, 2} contain two elements instead of ten twos?

    Brace initialization can select the initializer-list constructor. The two numbers then describe actual elements rather than count and repeated value.

  12. Why does brace initialization reject a conversion accepted by assignment?

    List initialization restricts narrowing conversions. That diagnostic exposes potential loss rather than a random inconsistency between syntax forms.

  13. Why is Widget item(Factory()) parsed as a function declaration?

    Some expressions that resemble object construction can be parsed as declarations. The resulting error may appear later when member access expects an object.

  14. Why does a template declaration compile but its specialization fail to link?

    Implicit instantiation generally needs the relevant definition to be reachable. Placing only a generic declaration in a header and its body in an unrelated source file may leave required specializations unavailable.

  15. Why does a template need typename before T::value_type?

    In a dependent context, the parser may not know that a qualified name denotes a type. The disambiguator states that intended interpretation.

  16. Why does a dependent member template call need the template keyword?

    After a dependent object expression, the parser may interpret the less-than token as an operator unless told that a member template name follows.

  17. Why does a vector of unique_ptr reject initializer-list construction?

    An initializer list exposes its elements as const values. Building a vector from that sequence normally requires copying them, which conflicts with exclusive move-only ownership.

  18. Why does vector copy my objects during growth despite a move constructor?

    Exception guarantees influence whether a container can safely move existing elements. A potentially throwing move may lead to copying when a suitable copy exists.

  19. Why can throwing from a destructor terminate exception unwinding?

    Another exception escaping cleanup while an earlier exception is already unwinding can end the program. Destructors are a poor place for ordinary recoverable failure reporting.

  20. Why is my class destructor not called when its constructor throws?

    A failed construction never produces a complete object whose destructor can run normally. Already constructed subobjects are cleaned up, which is why raw resources acquired directly in the constructor body are risky.

  21. Why does destroying a joinable std::thread terminate the program?

    std::thread destruction does not silently choose whether to wait or detach. A joinable thread reaching its destructor violates its required lifecycle decision.

  22. Why can condition_variable.wait wake before work is ready?

    A notification is not a stored permission, and waits can return without the application predicate being satisfied. Treating wakeup alone as readiness races with other consumers.

  23. How do I avoid deadlock when two operations acquire the same mutex pair in reverse order?

    Independent lock acquisition can form a cycle when one thread holds A waiting for B while another holds B waiting for A.

  24. Why does an atomic counter still oversell a limited capacity?

    An atomic read followed by a separate atomic decrement is not one indivisible check-and-update. Multiple threads can pass the check before any reserves capacity.

Ask your own question · Sign in to post questions and answers.