Charles,

Do you get fed up with having to specify the pesky tr1 namespace? It makes it difficult to share code between z/OS and distributed. You can work around that with a useful namespace declaration. Also, if you are using LANGLVL(EXTENDED0X) you can significantly cut down on the verbosity of variable definitions by using auto type inference.

#include <cstdio> // bring C stdio runtime into the std namespace

#define __IBMCPP_TR1__ 1
#include <regex>

namespace std { using namespace tr1; }  // be gone pesky tr1 namespace

struct myRegex
{
    std::regex regexObject;
};

int main(int argc, char* argv[])
{
    printf("RegEx test 4/6/2018\n");
    auto flags = std::regex::extended;     // necessary for error
    auto *myRegex_p = new myRegex;
    myRegex_p->regexObject.assign("foo", flags);
    delete myRegex_p;
    return 0;
}

On 9/04/2018 2:09 AM, Charles Mills wrote:
Believe it or not, it appears to be a bug in the C++ runtime. Anyone who
wants to prove me wrong is welcome to try the below. I have tested only on
z/OS V2R2.

#include <stdio.h>

#define __IBMCPP_TR1__ 1
#include <regex>

class myRegex
{
public:
     std::tr1::regex regexObject;
};

int main(int argc, char* argv[])
{
     printf("RegEx test 4/6/2018\n");
     std::tr1::regex::flag_type flags = std::tr1::regex::extended;     //
necessary for error
     myRegex *myRegex_p = new myRegex;
     myRegex_p->regexObject.assign("foo", flags);
     delete myRegex_p;
     return 0;
}

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Charles Mills
Sent: Friday, April 6, 2018 6:00 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Any C++ regex template class gotchas?

X-posted to IBM-MAIN and MVS-OE. (The latter seems more appropriate but the
former has more traffic by far.)

I'm trying to use the C++ template class regex for the first time. I have
code that works without any hint of an error on Windows but I am getting a
S0C4 on z/OS when the destructor calls some routine in the LE runtime
library. I've put in typical debugging checks for storage overlays with no
hint of an error.

Anyone know of any particular gotchas relative to the regex class for z/OS
C++?

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to