Comments (8)
This is weird. It’s true that a bool can hold values other than 0 or 1, but in general it shouldn’t, as it only gets initialized by the constants true or false, or by a logical operation like &&.
The values you’re seeing make me suspect something’s wrong. Where did that c4options struct come from? I suspect it may have been allocated/declared without getting initialized, so the fields contain garbage…
from cbforest.
The portion of the test I noticed this in was here:
C4AllDocsOptions options = kC4DefaultAllDocsOptions;
options.includeBodies = false;
e = c4db_enumerateAllDocs(db, kC4SliceNull, kC4SliceNull, &options, &error);
from cbforest.
In that case kC4DefaultAllDocsOptions
must not be initialized properly … the bools in there should all be 1 or 0. Is MSVC leaving the fields unmentioned in the initializer as garbage?
from cbforest.
I have it setup with the C position-based struct initializer (see https://github.com/couchbaselabs/cbforest/blob/feature/c_api/C/c4Database.cc#L611-L618). I don't quite know what is going on with that. I could try using (bool)1 I guess. I'm almost sure it is some weird compiler optimization because the C# bindings don't have this problem (You can't bind to a variable in C# so the defaults, etc, are all redefined in C#)
from cbforest.
Could you set a breakpoint and examine the contents of the struct to see if they're garbage? They shouldn't be, from what I know of the C standard, but it's possible this is a quirk of MSVC…
from cbforest.
I already did that, it's how I found the values I noted in the original ticket. The contents of the struct are weird. The variable examiner will show things like "true (233)" I wonder which standard is being applied here, because bool
is a C99 thing and we all know how MSVC fares with C99. However, it is also a C++ thing. Everything I look at says "this shouldn't happen" which frustrates me.
from cbforest.
This shouldn't happen. :/ It's in C++ code so there's no problem with bool
, and you're explicitly initializing every field of the struct to a valid value. If the fields don't have those values at runtime, it seems like the compiler screwed up.
from cbforest.
I've found another clue in this matter. It seems like ANY global const struct getting exported for use in CppTests is getting completely blown away for some reason with Visual Studio. Everything inside of it is garbage. This garbage just happened to be closer to the truth than the garbage I am dealing with now.
from cbforest.
Related Issues (20)
- Android: LogLevel does not effect for Android.
- After indexing a view, its lastSequenceIndexed may be less than db's lastSequence HOT 2
- RefCounted destructor can throw, triggering abort HOT 1
- InclusiveEnd=false query does not work unless end key is specified HOT 3
- Update ForestDB to get improved compaction / space reuse HOT 3
- ForestDB performance tanking on non SSD Window 10 machine HOT 5
- 1.4.0 ForestDb crash in _fdb_compact_file HOT 1
- Crash while compaction in background on iOS HOT 2
- After purging a doc, its rows are left behind in view indexes
- Allow enumerators to keep working after db or view is closed HOT 2
- ForestDB Error: null HOT 1
- Failed to begin transaction - com.couchbase.cbforest.Database.beginTransaction HOT 1
- KeyStore::lastSequence() could throw the exception. It should be caught.
- Crash in view
- C4Error: variables of struct is not initialized with 0 on Android platform HOT 4
- Crash in ForestDB (filemgr_is_fully_resident)
- Task: Update ForestDB to latest stable-branch commit HOT 1
- Multithreaded exception when indexing views
- Compilation warning with 64bit Android - type mismatch between unsigned long and unsigned long long HOT 4
- Multiple Transactions on same Database* cause assertion failure in thread-safe mode HOT 1
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 cbforest.