Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:26:31+00:00 2026-06-03T03:26:31+00:00

I am doing the convert type in Ocaml from int into int32 . I

  • 0

I am doing the convert type in Ocaml from int into int32. I changed some functions of String Ocaml’s library (code below)

external length : string -> int32 = "%string_length"
external create: int32 -> string = "caml_create_string"
external unsafe_blit : string -> int32 -> string -> int32 -> int32 -> unit
  = "caml_blit_string" "noalloc"

let sub s ofs len =
  if ofs < 0l or len < 0l or add ofs len > length s
  then invalid_arg "String.sub"
  else begin
    let r = create len in
    unsafe_blit s ofs r 0l len;
    r
  end

Note that I changed a lot of places in my code from int -> int32 when I run my code I got an error:

./xsd2coq < grammar/cpf.xsd > coq/cpf.v
Segmentation fault (core dumped)

In the file xsd2coq.ml I have an buffer with is:

let main () =

  let xml = parse_xml stdin in
  let xsds = Xsd_of_xml.xsd_of_xml xml in

  let b = Buffer.create 10000 in

  Coq_of_xsd.genr_ml b xsds;
  Buffer.output_buffer stdout b;;

let _ = run main;;

I would like to understand what are the reason that yield the error about segmentation fault? Could you please give me any hints or suggestion to be able to debug my code? Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:26:33+00:00Added an answer on June 3, 2026 at 3:26 am

    Well “%string_length” is an OCaml primitive. You can’t change its return type just by changing your OCaml code. You also have to change the code in the OCaml runtime. If OCaml tries to treat an int value (which is what you get from the runtime) as an int32 value, it will crash. An int32 value is going to be represented by a boxed value (a pointer), but an int value is an immediate value.

    It would be a lot of work to do what you’re trying to do. Since strings are quite limited in length (at least in a 32-bit architecture), I’m not sure it will be particularly useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write some code to convert data from a object type field
I am doing some exercises and tried to convert a simple class into a
The following code produces the issue Cannot implicitly convert type 'System.Collections.Generic.IEnumberable<DataField<string>>' to 'DataFields'. An
while doing LINQ I got this Error. Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'.
So I know I can convert a string to a hashcode simply by doing
How can i convert the 'dead' string to an unicode string u'\xde\xad' ? Doing
Doing an ajax get request works as expected using the following code: $.ajax({ type:
I saw in a blog that you can cast from string to int and
I'm doing some spring form validation, however I'm getting: Failed to convert property value
How can i convert this VBNet code into C#? ( ByteToImage is a User

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.