# Does not wrap raw pointer if set invalid argument in function call

**URL:** <https://forums.swift.org/t/does-not-wrap-raw-pointer-if-set-invalid-argument-in-function-call/13042>\
**Category:** Compiler\
**Tags:** bug\
**Created:** [May 30, 2018, 8:01am UTC](https://forums.swift.org/t/does-not-wrap-raw-pointer-if-set-invalid-argument-in-function-call/13042 "2018-05-30T08:01:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![qRoC](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/qroc/32/1603_2.png) [@qRoC](https://forums.swift.org/u/qRoC)\
**Post date:** [May 30, 2018, 8:01am UTC](https://forums.swift.org/t/does-not-wrap-raw-pointer-if-set-invalid-argument-in-function-call/13042/1 "2018-05-30T08:01:04Z")

</div>

```
swift --version  11:40:11
Apple Swift version 4.2-dev (LLVM b7ee930770, Clang 5bae8c2e73, Swift 4160301759)

```

Function signature for test:

```
public func pcre2_compile_16(
    _: PCRE2_SPTR16!,
    _: Int, 
    _: UInt32,
    _: UnsafeMutablePointer<Int32>!,
    _: UnsafeMutablePointer<Int>!,
    _: OpaquePointer!
) -> OpaquePointer!

```

Valid call:

```
let re = context.pattern.withCString(encodedAs: UTF16.self) {
            return pcre2_compile_16(
                    $0,
                    context.pattern.utf16.count,
                    0,
                    &errorCode,
                    &errorOffset,
                    nil
            )
        }

```

Call with invalid argument:

```
let re = context.pattern.withCString(encodedAs: UTF16.self) {
            return pcre2_compile_16(
                    $0,
                    context.pattern.utf16.count,
                    "hello", /// <--- must be UInt32, not String 
                    &errorCode,
                    &errorOffset,
                    nil
            )
        }

```

Actual results:

> cannot convert value of type 'UnsafePointer\<\_\>' to expected argument type 'PCRE2\_SPTR16?' (aka 'Optional\<UnsafePointer\>')
