Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

@WalterBright
Copy link
Member

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + druntime#2160"

@WalterBright WalterBright force-pushed the c_long branch 2 times, most recently from 089e1c9 to 693784a Compare April 10, 2018 03:50
@WalterBright
Copy link
Member Author

WalterBright commented Apr 10, 2018

* Both of these break existing code, so until we find a resolution the types are named
* cpp_xxxx.
*/
enum __c_long : int;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no clue that it was even legal to declare an enum with no members. That seems very weird. Is the point of doing this instead of using an alias so that it's a distinct type from int? I guess that that would mean that this technique is a typedef of sorts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the point of doing this instead of using an alias so that it's a distinct type from int?

Yes, so that the compiler can do special mangling for that type. Although I don't see how it's any better than a struct. I proposed to add support for adding pragma(mangle) to alias declarations but Walter doesn't seem to like that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go down that path, you'll discover you've reinvented enums.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmdavis BTW, one use case of declaring an enum without any members is to use it as a UDA that doesn't contain any data.

@WalterBright
Copy link
Member Author

This is a Vision issue, as it resolves a long-running sore in compatibility with C++.


version (Darwin)
{
alias cpp_size_t = cpp_ulong;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we do the other way around, i.e. alias size_t = cpp_ulong in object.d? This would be to avoid having to use cpp_size_t instead of size_t.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to do that separately.

@jacob-carlborg
Copy link
Contributor

I think there should be a test somewhere (in druntime or in DMD) that verifies that the correct mangling is used.

@WalterBright
Copy link
Member Author

I think there should be a test somewhere (in druntime or in DMD) that verifies that the correct mangling is used.

dlang/dmd#8152

@WalterBright
Copy link
Member Author

@CyberShadow I don't understand this error message:

Test the D Language specification
../dmd/generated/linux/release/64/dmd -run tools/dspec_tester.d --compiler=../dmd/generated/linux/release/64/dmd
---
void main() {
import std.stdio;
import std.algorithm;
int[] s = [1, 2, 3, 4];

copy(s[1..3], s[0..2]);
assert(s == [2, 3, 3, 4]);

}
---
gcc: error: __stdin.o: No such file or directory
Error: linker exited with status 1
struct.dd: 35 examples found
traits.dd: 1 examples found
template.dd: 1 examples found
type.dd: 4 examples found
arrays.dd: 31 examples found
function.dd: 36 examples found
posix.mak:811: recipe for target 'test_dspec' failed

@WalterBright
Copy link
Member Author

DAutoTest appears to fail the same way with other PRs, so is not caused by this PR.

@CyberShadow
Copy link
Member

The problem is in DMD's handling of programs from stdin:
https://issues.dlang.org/show_bug.cgi?id=18762#c1

@WalterBright
Copy link
Member Author

@CyberShadow thanks for the quick fix on that!

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move on with this then.

@dlang-bot dlang-bot merged commit 19b1d80 into dlang:master May 4, 2018
@WalterBright WalterBright deleted the c_long branch May 4, 2018 09:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Vision Vision Plan https://wiki.dlang.org/Vision/2018H1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants