Sign in to follow this  

[Answered]Runtime Error. What is instance of 'std::logic_error'

This topic is 4271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is anybody familiar with this error?
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct NULL not valid
Abort (core dumped)


I yahooed and googled them but apparently, no information was available. [Edited by - Tradone on April 3, 2006 10:07:20 PM]

Share this post


Link to post
Share on other sites
it's about 25 files all together. urm... do I have to still post it?

can you give me an example of what might have been done?
and where can I get information on standard runtime errors like those?
i searched them in the engines and i got no matches. :(

Share this post


Link to post
Share on other sites
okay, i fixed it

Error:

Function Parameter::GetData(){
long count = 0;
inputData = "";
char ch;

while (count < envVars.contentLength){
cin.get(ch);
inputData += ch;
count++;
}

if (inputData == "" )
return Failure;

return Success;
}




No Error:


Function Parameter::GetData(){
long count = 0;
inputData = "";
char ch;

while (count < envVars.contentLength){
cin.get(ch);
inputData += ch;
count++;
}

return Success;
}




Difference:

if (inputData == "" )
return Failure;



Thanks!
and if you can just leave me a reference site for the runtime errors.

Share this post


Link to post
Share on other sites
If you still want to check if it's a failure, simply check the string's length (>0).
Now, is the compiler assuming that "" is NULL? I thought it would be considered as {'\0'} or something like that...

Share this post


Link to post
Share on other sites
Quote:
Original post by deadimp
If you still want to check if it's a failure, simply check the string's length (>0).


Well, we don't even know what inputData, Success, Failure or Function are, so it's hard to pinpoint what he may be doing wrong.

Quote:
Now, is the compiler assuming that "" is NULL?


No.

Quote:
I thought it would be considered as {'\0'} or something like that...


Yes.

Share this post


Link to post
Share on other sites
Sorry, but I'm still not getting it. How does that conditional have anything to do with NULL character array initialization?
(My brain left after school)

Share this post


Link to post
Share on other sites

Function Parameter::GetData(){
long count = 0;
inputData = "";
char ch;

while (count < envVars.contentLength){
cin.get(ch);
inputData += ch;
count++;
}

if (inputData == "" )
return Failure;

return Success;
}

Function Parameter::SetParameter(){
string s;

if (!GetData())
return Failure;

s = inputData + "&";



[lol]
Seems like I left you guys all puzzled for not showing the whole thing.
okay. here it is.

So the I found out that Parameter::SetParameter() was the method with fault.

Thus, by adding

if (inputData == "" )
return Failure;


I don't have to execute this code.

s = inputData + "&";


and inputData is a private member variable of the class Parameter.

So since inputData = ""
I am trying to do
s = "" + "&"

Share this post


Link to post
Share on other sites
[edit] Whoops, that's not right...
I think I need to add that the error message is a little misleading:
Quote:
libstdc++
if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0))
  __throw_logic_error(__N("basic_string::_S_construct NULL not valid"));
So it will complain about NULL even if the char array is just empty ("\0").


Glad you fixed the problem.


jfl.

[Edited by - jflanglois on April 4, 2006 9:44:21 AM]

Share this post


Link to post
Share on other sites
oops my bad that wasn't the problem.
the real problem that was causing the thing was this:

getenv("QUERY_STRING")

so if there is no query string passed through the cgi, the returns a NULL.
Before:

if ( s == "&" ){
if ( !ParseGet( getenv("QUERY_STRING") ) )
return Failure;
}


After:

if ( s == "&" && getenv("QUERY_STRING") != NULL ){
if ( !ParseGet( getenv("QUERY_STRING") ) )
return Failure;
}


Difference:
getenv("QUERY_STRING") != NULL


So yea. That was the REAL reason.

Share this post


Link to post
Share on other sites

This topic is 4271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this