Comments (7)
Odd. I'll take a look at that a bit later.
from catch2.
Browsing the code a bit, the problem seems to be in catch_resultinfo.hpp:47.
expr
is an empty string, so the expression m_op( m_expr[0] == '!' ? "!" : "" )
blows up.
from catch2.
I've not had a chance to try this with MSVC yet (which version, btw?) - but it's very odd for several reasons.
- There is no difference between how an INFO in a SECTION is handled - and there are plenty of examples of INFO with a single string that have run happily in MSVC.
- expr should not be NULL - it should be "" in this case (see catch_capture:491) - so expr[0] should be '\0' (and that's what I see when I debug from XCode/ gcc).
- although expr is a raw char*, it's actually the, just constructed, m_expr that is being tested - which is a std::string. If it made it to there then m_expr[0] should always work.
That said I made a small change to check expr against NULL before checking expr[0]. Let me know if that changes anything. However I suspect that is not actually where your crash is.
If you could confirm which version of MSVC you're using - and any other context that may be relevant, I'll try and reproduce it (assuming my last check-in doesn't fix it).
from catch2.
expr
isn't NULL, it's an empty string, as you expected.
But expr[0]
is not valid on an empty string, and so in debug mode, MSVC's extra debug validation will trigger an assert when you try to index into the string. (In release mode, and, I assume, on other compilers, no such assert is in place, and so it happily exceeds the end of the (empty) string, and returns the null character at the end of the buffer. That's relying on undefined behavior though, and so in debug builds, MSVC detects it and triggers an assert.
But it seems that, rather than checking against NULL, you need to check against expr.empty()
from catch2.
Yes, of course, you are right. If I'd done m_expr.c_str()[0] then it would have forced the null terminator.
So it sounds like my "fix" is really a fix. I'm checking expr against NULL - which is a const char*, rather than m_expr, which is the std::string. Did you try it out?
from catch2.
I'm without a working compiler for a day or so, so I haven't been able to try it out with your fix yet. But you're right, it looks as if that should solve it. I'll give it a try tomorrow.
from catch2.
Finally got everything set up on my new laptop so I could try it. It works perfectly, of course. Nicely done. :)
from catch2.
Related Issues (20)
- Separate headers for "extra" std types
- Catch2 does not appear to work with C++23
- version 3.5.4 does not compile
- JUnit and console reporter discrepency.
- Provide means to obtain current test case name and current section name HOT 2
- GENERATOR doesn't allow use constants HOT 1
- Memory leak when using exit()
- Compile Error While using Catch::Clara::Parser HOT 1
- Allow the Catch2 library to be compiled with address sanitizer enabled
- Fixture's destructor called before retrieving uncaught exception's message
- How does (can) auto-registration work?
- CTest (using catch_discover_tests) treats skipped tests as failed HOT 2
- Exit code of 127 when all tests pass (only on Windows Release build) HOT 1
- std::complex output precision
- How to test a custom math library with Catch2 (while catch2 relies on libm) ? HOT 1
- The json reporter does not print results of benchmarks HOT 4
- `enableBazelEnvSupport` behavior breaks test executions relying on memory allocation free test execution HOT 2
- How to output benchmark custom meta data correctly HOT 2
- Remove final keyword from first party reporters HOT 3
- Command line options --list-tests and --list-tags are missing their short forms.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catch2.