Any C++ regex template class gotchas?

2018-04-06 Thread Charles Mills
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++?

Thanks,

Charles

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Charles Mills
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 

#define __IBMCPP_TR1__ 1
#include 

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 12:09 PM, 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.


No convenient access, but let me guess: blows up in the delete?

Got an error message?

--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Charles Mills
It do. The error message is ABEND=S0C4 U REASON=0004.

Traceback:  
  
  DSA   Entry   E  Offset  Statement   Load Mod Program Unit
   Service  Status
  1 CEEHDSP +4A4C  CEEPLPKA CEEHDSP 
   HLE77A0  Call  
  2 std::tr1::_EBCDIC::_Destroy(std::tr1::_EBCDIC::_Node_base*) 
  
+0066  40  CRTE128N 
Exception 
  3 std::tr1::_EBCDIC::basic_regexmailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Jack J. Woehr
Sent: Sunday, April 8, 2018 2:59 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

On 4/8/2018 12:09 PM, 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.

No convenient access, but let me guess: blows up in the delete?

Got an error message?

-- 
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe 
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

--
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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 1:04 PM, Charles Mills wrote:

It do. The error message is ABEND=S0C4 U REASON=0004.


Try initializing the regex in the declaration instead of doing it in 
main() via pointer-to-reference;


--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Charles Mills
Thanks, but won't work well in the real code.

I have multiple instantiations of the same class, and don't know the pattern 
until well after the instantiation. Pattern may change after instantiation.

It doesn't take much to make it work. The std::tr1::regex::flag_type flags = 
std::tr1::regex::extended is necessary. ECMA (the default) works.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Jack J. Woehr
Sent: Sunday, April 8, 2018 3:18 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

On 4/8/2018 1:04 PM, Charles Mills wrote:
> It do. The error message is ABEND=S0C4 U REASON=0004.

Try initializing the regex in the declaration instead of doing it in
main() via pointer-to-reference;

-- 
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe 
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

--
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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 1:43 PM, Charles Mills wrote:

Thanks, but won't work well in the real code.


I just meant as a debugging step. Make it work, then make it break again 
and you're home.


--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 1:43 PM, Charles Mills wrote:

Thanks, but won't work well in the real code.


Besides, the C++ way to do that is to have subclasses with increasingly 
specific ctors for your needs, not mess with a template's internal data 
in main().


Betcha if you work on the class design a little it will "magically" 
start working.


--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Charles Mills
I'm not "messing" -- .assign() is a documented, public method.

http://www.cplusplus.com/reference/regex/basic_regex/assign/

The pattern is supplied at run time -- as is typical of regex implementations 
-- so no number of subclasses solves the problem.

It would conceivably be possible to pass the pattern on the ctor but that is 
not how the code works. I get the pattern well after ctor time. (Could I do a 
new instead of having it declared in the class header? Sure, I could. But why 
should I? I firmly believe this is a bug, and I do have a workaround, letting 
the flag default to ECMA.) For a given instance, the pattern can change from 
time to time -- should be supported by the class AFAIK.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Jack J. Woehr
Sent: Sunday, April 8, 2018 4:49 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

On 4/8/2018 1:43 PM, Charles Mills wrote:
> Thanks, but won't work well in the real code.

Besides, the C++ way to do that is to have subclasses with increasingly 
specific ctors for your needs, not mess with a template's internal data in 
main().

Betcha if you work on the class design a little it will "magically" 
start working.

-- 
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe 
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

--
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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 2:58 PM, Charles Mills wrote:

  I firmly believe this is a bug, and I do have a workaround, l



I'll betcha it's not a bug, it's something about the flags being out of 
scope before the dtor is called for the object.


C++ is, to put it mildly, design-heavy.

You can prove it if you write the equivalent code on your home Linux box 
and it blows up there, too.


--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Jack J. Woehr

On 4/8/2018 2:58 PM, Charles Mills wrote:

The pattern is supplied at run time -- as is typical of regex implementations 
-- so no number of subclasses solves the problem.


Put the flags in the same scope as the regex and naybe it doesn't blow up.

Either forget about your RegexObject and just do the regex inline in 
main() in which case you need no dtor, or put the flags instantiation 
inside the Regex Object.


--
Jack J. Woehr # Science is more than a body of knowledge. It's a way of
www.well.com/~jax # thinking, a way of skeptically interrogating the universe
www.softwoehr.com # with a fine understanding of human fallibility. - Carl Sagan

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread David Crayford

Works ok for me. The code is sound so I would open a PMR.


On 9/04/2018 2:09 AM, Charles Mills wrote:

#include 

#define __IBMCPP_TR1__ 1
#include 

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;
}


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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread David Crayford

On 9/04/2018 3:18 AM, Jack J. Woehr wrote:

On 4/8/2018 1:04 PM, Charles Mills wrote:

It do. The error message is ABEND=S0C4 U REASON=0004.


Try initializing the regex in the declaration instead of doing it in 
main() via pointer-to-reference;




That's not a pointer-to-reference. A pointer-to-reference is declared 
like so '*&'.


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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread Andrew Rowley

On 9/04/2018 4:09 AM, Charles Mills wrote:

#include 

#define __IBMCPP_TR1__ 1
#include 

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;
}
C++ isn't my first language and I'm not even sure I found the right 
documentation, but does assign create a new regex rather than modifying 
the existing one?


What is the scope of the new Regex? And templates can create different 
classes based on the parameters so the result of regexObject.assign may 
not even be the same type of object as when myRegex was instantiated.


I'm not sure if that is allowed or not - this sort of stuff is why I 
avoid C++, too complex for me :-)


--
Andrew Rowley
Black Hill Software
+61 413 302 386

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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread David Crayford

On 9/04/2018 8:51 AM, Andrew Rowley wrote:

On 9/04/2018 4:09 AM, Charles Mills wrote:

#include 

#define __IBMCPP_TR1__ 1
#include 

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;
}
C++ isn't my first language and I'm not even sure I found the right 
documentation, but does assign create a new regex rather than 
modifying the existing one?


What is the scope of the new Regex? And templates can create different 
classes based on the parameters so the result of regexObject.assign 
may not even be the same type of object as when myRegex was instantiated.




There are two classes created for C++ regex's, basic_regex and 
basic_regex. One for 8-bit chars and one for unicode 16-bit 
chars. Assign replaces the existing regex with a new one. In Charles 
case he hasn't

created a regex in the constructor so assign will just create a new one.

The scope is until delete is called. This is not idiomatic C++ where the 
MyRegex object would be instantiated on the stack and the scope is 
whatever the outer {} braces are. Deterministic resource finalization is 
one of the strengths of
C++ and I would take it over Java GC any day of the week. It's also 
unusual to see the use of the new operator in modern C++ where raw 
pointers are generally banned by coding standards. One would use 
make_unique or make_shared

or on z/OS which doesn't fully support C++11 shared_ptr(new T).

I'm not sure if that is allowed or not - this sort of stuff is why I 
avoid C++, too complex for me :-)




Indeed! Complex it most certainly can be. Having said that if you're 
lucky enough to have a modern C++ compiler and keep it simple it's 
actually an easy language to learn and incredibly powerful.


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


Re: Any C++ regex template class gotchas?

2018-04-08 Thread David Crayford

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  // bring C stdio runtime into the std namespace

#define __IBMCPP_TR1__ 1
#include 

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 

#define __IBMCPP_TR1__ 1
#include 

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


Re: Any C++ regex template class gotchas?

2018-04-09 Thread Charles Mills
David -

Thanks for everything. I guess I will PMR it. As pointed out in another thread, 
the PMR process is painful. It does me little good because I can't ship a 
product that requires some obscure PTF -- the sales team would kill me.

Nah, the tr1 doesn't bother me. It's like having to code those pesky semicolons 
or those pesky double equal signs. It is what it is. My Visual Studio accepts 
but does not require the tr1:: for regex. I use Visual Assist and it tends to 
autocomplete these things for me anyway, so it is little trouble.

I used namespace when I started out in C++ but then decided I was collapsing 
the name space. I would rather have to code std:: every time than to have some 
weird problem caused by an unexpected symbol name duplication.

I use auto sometimes but tend not to think to use it except in template 
functions and that sort of thing.

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Monday, April 9, 2018 12:38 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

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  // bring C stdio runtime into the std namespace

#define __IBMCPP_TR1__ 1
#include 

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 
>
> #define __IBMCPP_TR1__ 1
> #include 
>
> class myRegex
> {
> public:
>  std::tr1::regex regexObject;
> };
>

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


Re: Any C++ regex template class gotchas?

2018-04-09 Thread David Crayford

On 9/04/2018 7:55 PM, Charles Mills wrote:

David -

Thanks for everything. I guess I will PMR it. As pointed out in another thread, 
the PMR process is painful. It does me little good because I can't ship a 
product that requires some obscure PTF -- the sales team would kill me.


I feel your pain.



Nah, the tr1 doesn't bother me. It's like having to code those pesky semicolons 
or those pesky double equal signs. It is what it is. My Visual Studio accepts 
but does not require the tr1:: for regex. I use Visual Assist and it tends to 
autocomplete these things for me anyway, so it is little trouble.

I used namespace when I started out in C++ but then decided I was collapsing 
the name space. I would rather have to code std:: every time than to have some 
weird problem caused by an unexpected symbol name duplication.


Me too. I avoid usings like "using namespace std". The using I posted 
brings the tr1 namespace into std so I can use std::regex and not 
std::tr1::regex. I don't use visual studio and clang and g++ require 
including special headers like  which I would rather not do.



I use auto sometimes but tend not to think to use it except in template 
functions and that sort of thing.


auto has moved on significantly since C++14 and C++17 and you can now 
define a function with an auto return value. It's also important for 
lambda's. Especially useful for iterators so you don't have to code 
something like std::unsorted_map::iterator or use 
typedefs.




Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Monday, April 9, 2018 12:38 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

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  // bring C stdio runtime into the std namespace

#define __IBMCPP_TR1__ 1
#include 

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 

#define __IBMCPP_TR1__ 1
#include 

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


--
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


Re: Any C++ regex template class gotchas?

2018-04-09 Thread Jerry Callen
Works for me, using exactly the code posted, so it looks like something 
peculiar to your maintenance level. I'd open a PMR.

make -k CHARSET=ebcdic
xlC -Wc,phaseid -qebcdic -q64 -qnocse -qgonum -qbitfield=signed 
-qtarget=zosv2r2 -qarch=10 -qstrict \
 -qfloat=ieee:nomaf -qlanglvl=extended0x -O2  -DNDEBUG -D__MV17195__ 
-D_XOPEN_SOURCE=600  -o test1 
test1.cpp
CCN(I) Product(5650-ZOS) Phase(CCNEOPTP) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNDRVR ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNEPP  ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNETBY ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNECWI ) Level(D171026.Z2R2)
./test1
RegEx test 4/6/2018


FWIW, it's a good idea to post the compile and link lines along with the source 
code, as they can dramatically affect the outcome. Good luck!

-- Jerry

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


Re: Any C++ regex template class gotchas?

2018-04-09 Thread Charles Mills
To clarify, by "works" you mean does NOT ABEND?

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Sunday, April 8, 2018 7:02 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

Works ok for me. The code is sound so I would open a PMR.


On 9/04/2018 2:09 AM, Charles Mills wrote:
> #include 
>
> #define __IBMCPP_TR1__ 1
> #include 
>
> 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;
> }

--
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


Re: Any C++ regex template class gotchas?

2018-04-09 Thread Charles Mills
I compile with JCL. Everyone laughs at me here if I say that, so I avoid 
mentioning it. 

Here are the compile options that I tested this with.

   OPT(0) NOINLINE   TEST   
 
   TARG(LE,zOSV1R13)
 
   ARCH(9) TUNE(10) 
 
   GONUMBER 
 
   NOTEMPL,OE,OBJ,HALT(8),LONGNAME 
   LANGLVL(NEWEXCP,UCS,DOLLARINNAMES)   
 
   RTTI 
 
   ENUMSIZ(INT) 
 
   AGGRCOPY HGPR LIBANSI
 
   ANSIALIAS UNROLL(YES)
 
   ROCONST  
 
   SUPP(CCN5802)
 
   DLL(CBA) 
 

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Jerry Callen
Sent: Monday, April 9, 2018 10:09 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

Works for me, using exactly the code posted, so it looks like something 
peculiar to your maintenance level. I'd open a PMR.

make -k CHARSET=ebcdic
xlC -Wc,phaseid -qebcdic -q64 -qnocse -qgonum -qbitfield=signed 
-qtarget=zosv2r2 -qarch=10 -qstrict \  -qfloat=ieee:nomaf -qlanglvl=extended0x 
-O2  -DNDEBUG -D__MV17195__ -D_XOPEN_SOURCE=600  -o test1 test1.cpp
CCN(I) Product(5650-ZOS) Phase(CCNEOPTP) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNDRVR ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNEPP  ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNETBY ) Level(D171026.Z2R2)
CCN(I) Product(5650-ZOS) Phase(CCNECWI ) Level(D171026.Z2R2)
./test1
RegEx test 4/6/2018


FWIW, it's a good idea to post the compile and link lines along with the source 
code, as they can dramatically affect the outcome. Good luck!

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


Re: Any C++ regex template class gotchas?

2018-04-10 Thread Charles Mills
Auto seems to have some sort of limitations

auto regex_p = new std::tr1::regex("foo", flags);

"/u/xx/FEB2018/Source/SANDBOX.C", line 27.20: CCN5257 (S) An object or 
reference of type "int" cannot be
initialized with an expression of type 
"std::tr1::_EBCDIC::basic_regex > *".

z/OS V2R2

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Monday, April 9, 2018 9:33 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

On 9/04/2018 7:55 PM, Charles Mills wrote:
> David -
>
> Thanks for everything. I guess I will PMR it. As pointed out in another 
> thread, the PMR process is painful. It does me little good because I can't 
> ship a product that requires some obscure PTF -- the sales team would kill me.

I feel your pain.

>
> Nah, the tr1 doesn't bother me. It's like having to code those pesky 
> semicolons or those pesky double equal signs. It is what it is. My Visual 
> Studio accepts but does not require the tr1:: for regex. I use Visual Assist 
> and it tends to autocomplete these things for me anyway, so it is little 
> trouble.
>
> I used namespace when I started out in C++ but then decided I was collapsing 
> the name space. I would rather have to code std:: every time than to have 
> some weird problem caused by an unexpected symbol name duplication.

Me too. I avoid usings like "using namespace std". The using I posted brings 
the tr1 namespace into std so I can use std::regex and not std::tr1::regex. I 
don't use visual studio and clang and g++ require including special headers 
like  which I would rather not do.

> I use auto sometimes but tend not to think to use it except in template 
> functions and that sort of thing.

auto has moved on significantly since C++14 and C++17 and you can now define a 
function with an auto return value. It's also important for lambda's. 
Especially useful for iterators so you don't have to code something like 
std::unsorted_map::iterator or use typedefs.

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


Re: Any C++ regex template class gotchas?

2018-04-10 Thread Charles Mills
Initializing in the constructor no help:

std::tr1::regex *regex_p = new std::tr1::regex("foo", flags);
// here we would use the regex
delete regex_p;

CEE3204S The system detected a protection exception (System Completion 
Code=0C4). 
 From entry point 
std::tr1::_EBCDIC::_Destroy(std::tr1::_EBCDIC::_Node_base*) at statement 40 at 
compile unit 
 offset +0066 at entry offset +0066 at address 15E5C7CE.
  

Charles

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


Re: Any C++ regex template class gotchas?

2018-04-10 Thread David Crayford
It seems that you don't have extended0x defined as regex_p is defaulting 
to an integer.



On 10/04/2018 6:26 PM, Charles Mills wrote:

Auto seems to have some sort of limitations

 auto regex_p = new std::tr1::regex("foo", flags);

"/u/xx/FEB2018/Source/SANDBOX.C", line 27.20: CCN5257 (S) An object or reference of 
type "int" cannot be
initialized with an expression of type 
"std::tr1::_EBCDIC::basic_regex > *".

z/OS V2R2

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Monday, April 9, 2018 9:33 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

On 9/04/2018 7:55 PM, Charles Mills wrote:

David -

Thanks for everything. I guess I will PMR it. As pointed out in another thread, 
the PMR process is painful. It does me little good because I can't ship a 
product that requires some obscure PTF -- the sales team would kill me.

I feel your pain.


Nah, the tr1 doesn't bother me. It's like having to code those pesky semicolons 
or those pesky double equal signs. It is what it is. My Visual Studio accepts 
but does not require the tr1:: for regex. I use Visual Assist and it tends to 
autocomplete these things for me anyway, so it is little trouble.

I used namespace when I started out in C++ but then decided I was collapsing 
the name space. I would rather have to code std:: every time than to have some 
weird problem caused by an unexpected symbol name duplication.

Me too. I avoid usings like "using namespace std". The using I posted brings the tr1 
namespace into std so I can use std::regex and not std::tr1::regex. I don't use visual studio 
and clang and g++ require including special headers like  which I would rather 
not do.


I use auto sometimes but tend not to think to use it except in template 
functions and that sort of thing.

auto has moved on significantly since C++14 and C++17 and you can now define a 
function with an auto return value. It's also important for lambda's. Especially 
useful for iterators so you don't have to code something like 
std::unsorted_map::iterator or use typedefs.

--
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


Re: Any C++ regex template class gotchas?

2018-04-10 Thread Charles Mills
That fixed it. Thanks,

Charles


-Original Message-
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Tuesday, April 10, 2018 8:31 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Any C++ regex template class gotchas?

It seems that you don't have extended0x defined as regex_p is defaulting to an 
integer.

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


Re: Any C++ regex template class gotchas?

2018-04-11 Thread Jerry Callen
On Mon, 9 Apr 2018 10:28:34 -0400, Charles Mills  wrote:

>To clarify, by "works" you mean does NOT ABEND?

Oops, yes, I meant "does not ABEND".

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