Most active questions
4,628 questions from the last 7 days
13
votes
5
answers
599
views
How to return the results only when matching is true in R gsub()
I'm working with a character vector in R (test) where I need to extract specific parts of strings that match a pattern while discarding the original strings that don't match.
My current solution is ...
14
votes
3
answers
2k
views
Why is it ok to cast to an undeclared struct pointer in C?
Why does this code compile? struct test is not even forward declared.
int main(){
*(int*)((struct test*) 0x1234) = 0x0;
return 0;
}
13
votes
1
answer
1k
views
Is it safe to catch stack overflows? Can it leave objects in messy/intermediate states?
I've been reviewing ways to kill threads in Java, and the overwhelming conclusion is that it is never safe to stop code at arbitrary points - doing so may leave resources in messy intermediate states. ...
8
votes
2
answers
3k
views
React Native Expo + Firebase Auth: “Component auth has not been registered yet” on app launch
I’m building an Expo (SDK 53) React Native app with Firebase Authentication and I keep getting this error on startup:
[runtime not ready]: Error: Component auth has not been registered yet, js engine: ...
4
votes
2
answers
201
views
"Too many open files" after 1 month runtime [duplicate]
I have a Spring Boot app that checks for files every 10s.
@Scheduled (fixedRateString = "10000")
public void foo ()
{
try
{
List <Path> ps = Files.list (Path.of (&...
-3
votes
3
answers
182
views
Alternative to 'while(true) break' for sequential condition chain? [closed]
I have some code that uses a while(true) loop to ensure a sequence of conditions are met before performing an action. Any condition not met would break the sequence so the end action is not performed....
4
votes
5
answers
114
views
Assign a number for every matching value in list
I have a long list of items that I want to assign a number to that increases by one every time the value in the list changes. Basically I want to categorize the values in the list.
It can be assumed ...
11
votes
1
answer
513
views
MSVC calls wrong virtual method when storing a pointer to virtual method in a static inline variable
I'm encountering unexpected behavior on MSVC when storing a pointer to a virtual method in a static inline variable. The issue does not occur on GCC or Clang.
Specifically, when I store a pointer to a ...
10
votes
1
answer
235
views
Why can this C++ code pass compile check? [duplicate]
I accidentally added a semicolon in an expression constructing std::string, but the compiler happily accepted it without complaining anything.
I did a minimum reproducible example below, kindly teach ...
5
votes
1
answer
172
views
Assignment in (else) if statement triggers warning in MSVC but not in gcc / clang
This code snippet triggers a warning in MSVC (VS2022 17.10.2).
int m = 0;
if(int i = m)
// ...
else if (int i = m) // warning C4456: declaration of 'i' hides previous local declaration
// ...
...
1
vote
4
answers
245
views
std::vector: when is a pointer not a pointer?
I have this existing working code, which I am trying to convert to implementation:
Bitmap *pbitmap = new Bitmap(L"images.png");
nWidth = pbitmap->GetWidth();
nHeight = pbitmap->...
3
votes
2
answers
102
views
C++: `if constexpr` and `std::is_same_v` not working
I'm playing around with templates, compile-time evaluation and pointers to members.
I don't understand why the following code doesn't set a.x to 42 and a.y to 3.14. According to the output, FieldType ...
20
votes
1
answer
1k
views
CoreWCF stream continues to be written to after client disconnects
I have a very simple service class:
using System.Diagnostics;
var builder = WebApplication.CreateBuilder();
builder.Services.AddServiceModelServices();
builder.Services.AddServiceModelMetadata();
...
3
votes
3
answers
127
views
How do you convert a single surrogate character without a pair into its UTF-8 equivalent?
I am experimenting with wctomb in order to convert a wchar_t into its UTF-8 equivalent stored in a char[]. It works nicely, but not for surrogate characters ranging U+D800 to U+DFFF.
int ret;
// null-...
0
votes
2
answers
176
views
Invalid comparator in std::sort due to correct same result in both orders
I'm sorting a vector of structs, std::vector<DRIVE_OR_DIR>, where DRIVE_OR_DIR is defined as
typedef struct {
std::string path;
boolean isDrive;
} DRIVE_OR_DIR
The idea is that elements ...