Jump to content

Fraser

Members
  • Content Count

    44
  • Joined

  • Last visited

Posts posted by Fraser


  1. Quote

    I would not have expected this code to compile, but if it does then it has undefined behavior.

    It is not my function, it's a mock-up.  My function calls exit so it does not throw again and can be declared noexcept.

    Quote

    You are constructing an A object in global scope before Winmain() is called, you are not waiting for AccessA() to be called first.

    I don't know what you are saying.  a and AccessA() are diferent implementations that I am trying out and never used together.

    Quote

    That global object is throwing an exception that is not being caught, thus aborting the process startup.

    It has a handler so why wouldn't it be caught?  It is caught when constructing obj.

    Quote

    But the exception is not being swallowed by the catch handler, it is being re-thrown.

    For obj's exception it is caught and the handler executes correctly and there is not another throw.


  2. For obj the initial message is Project X.exe raised exception class $std@logic_error with message 'Exception Object Address:0x2EAAE98'.

    For a the initial message is similar.  Next there is Project X.exe raised exception class EExternalException with message 'Extrenal Exception EEFACE'.  Next there is another before 'Abnormal program termination.'



  3. #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;

    class A {
        A() noexcept try {
        throw std::logic_error("test");
        }
        catch (std::exception const &ex) {
            std::cout << "Caught an STL exception" << std::endl;
            }
        };

    A a;

    A & AccessA() {
        static A obj;
        return obj;
        }

     

    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------

     

    The throw is placed there as a deliberate test.  The object a throws an exception and it gets caught by the handler but the CPU view shows that a function called clang terminate is called.  The object obj throws an exception and it gets caught by the handler and the correct code is executed.


  4. I am not sure what is happening when I export functions with __cdecl.  When I build with 32-bit clang there is one prefixed underscore on all function names.  When I build with 64-bit clang there is no prefixed underscore on function names.  The documentation says this about cdecl: "Note: This feature is available only for the classic bcc32 compiler, not for the modern Clang-enhanced compiler."  It also says:"Note: The __cdecl form is the only one supported by C++Builder 64-bit Windows (BCC64)."  Is this not a contradiction?

     

    The compiler option "Generate underscores on symbol names" made no difference to my 32-bit builds.  I have not found any way of using cdecl with 32-bit builds and to not get leading underscores which means I cannot build zlib1.dll which specifies no underscores.


  5. If I have an object with static storage duration that throws an exception while constructing it is not caught by the expected catch statement.  Instead there is an external exception EEFACE and 'Abnormal program termination' is reported.  This only happens with a VCL application.  The code would work otherwise.  I have to have my object declared static in a function that returns it by reference in order that its construction will be delayed until after something clearly VCL related.  This must be something that is known about.  I am not providing example code because the requirements for this are described adequately.  BTW this is not the undeterminable order of construction of objects of static storage duration problem.


  6. I am using C++ Builder 10.4 with Dinkumware 8.03.  The non-member function std::cbegin sometimes returns an iterator when it should always be a const_iterator.  The following program will not compile due to b1 being deduced as iterator and b2 a const_iterator.  There is no problem with c1 and c2.  The fix is to add const to the parameter _Container & as described in the book.

     

     

    int _tmain(int argc, _TCHAR* argv[])
    {
        std::vector<int> a1(100, 2);
        std::vector<int> const a2(100, 3);
        auto const
            b1= std:: cbegin(a1),
            b2= std::cbegin(a2);
        /*auto const
            c1= a1.cbegin(),
            c2= a2.cbegin();  */
       // See item 13 of Effective Modern C++ for explanation.
        return 0;
    }

     /* line 1672 of xiter
    template<class _Container>
    _CONST_FUN auto inline cbegin(_Container& _Cont) _NOEXCEPT_OP(_NOEXCEPT_OP(_STD begin(_Cont)))
            -> decltype(_STD begin(_Cont))
        {    // get beginning of sequence
        return (_STD begin(_Cont));
        }     */


  7. There is something not right with the integrated debugger.  If you step into the concatenation and out again you will see what you expect.  Is it a mistake that you assign a wide character string literal to a char based string type?


  8. On my Windows start button menu some shortcuts of C++ Builder are missing from view but they are present in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Embarcadero RAD Studio 10.1 Berlin.  With 10.4 Rad Studio Command Prompt and Uninstall are missing and with 10.3 only Uninstall is missing.  With 10.1 another couple are missing.


  9. When I type #include < characters get entered automatically that I don't want.  I'm not sure what this technology is called but it is a pain.  I have some of my own headers that I include with <> because they are used by multiple projects.  How is this turned off?  I have 10.4 Community.

    • Like 1
×