Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build of ADT/SmallPtrSet fails #1606

Closed
llvmbot opened this issue Mar 1, 2007 · 7 comments
Closed

Build of ADT/SmallPtrSet fails #1606

llvmbot opened this issue Mar 1, 2007 · 7 comments
Labels
bugzilla build-problem

Comments

@llvmbot
Copy link
Collaborator

@llvmbot llvmbot commented Mar 1, 2007

Bugzilla Link 1234
Resolution FIXED
Resolved on Feb 22, 2010 12:53
Version 1.0
OS MacOS X
Reporter LLVM Bugzilla Contributor

Extended Description

Building CVS HEAD on MacOSX fails with the following error:

$ make
make[1]: Nothing to be done for `all'.
llvm[1]: Compiling SmallPtrSet.cpp for Debug build
/Users/andreas/build/llvmHEAD/llvm/include/llvm/ADT/SmallPtrSet.h:191: error: non-constant ‘((N |
(N - 1)) + 1)’ cannot be used as template argument
/Users/andreas/build/llvmHEAD/llvm/include/llvm/ADT/SmallPtrSet.h:191: error: ‘Val’ is not a
member of ‘’
make[1]: *** [/Users/andreas/build/llvmHEAD/llvm/lib/Support/Debug/SmallPtrSet.o] Error 1
make: *** [all] Error 1

@llvmbot
Copy link
Collaborator Author

@llvmbot llvmbot commented Mar 1, 2007

The code in question is this:

template
struct NextPowerOfTwoH<N, false> {
enum {
// We could just use NextVal = N+1, but this converges faster. N|(N-1) sets
// the right-most zero bits to one all at once, e.g. 0b0011000 -> 0b0011111.
NextVal = (N|(N-1)) + 1,
Val = NextPowerOfTwo::Val
};
};

It does look wrongish and stuff. Are we depending on a compiler feature here?

@lattner
Copy link
Collaborator

@lattner lattner commented Mar 1, 2007

N certainly is a constant. what version of G++ are you compiling with?

@llvmbot
Copy link
Collaborator Author

@llvmbot llvmbot commented Mar 2, 2007

I use the default g++ that comes with MacOSX 10.4 (g++ 4.1?). I don't have
access to that computer right now, but I'll check later today. Can anyone else
reproduce this?

I think the compiler is wrong; I've extracted the NextPowerOfTwo stuff and
tested it with g++ 3.4 and 4.1 on linux, Visual C++ 2005, and Comeau C++, and it
all works.

Also, I don't think that it is the "(N|(N-1))+1" part that causes the problem
because I could compile small tests with similar constructs without any
problems. I experimented a bit, and it seems that line 192 is needed to get
the error.

191: NextVal = (N|(N-1)) + 1,
192: Val = NextPowerOfTwo::Val

Maybe, it is the fact that NextPowerOfTwo::Val is "forward declared" when
referenced at line 192 that confuses the compiler (although it shouldn't)?

This is all from memory right now, but I'll post more detailed information later
today when I get access to my mac.

@llvmbot
Copy link
Collaborator Author

@llvmbot llvmbot commented Mar 2, 2007

$ g++ --version
powerpc-apple-darwin8-g++-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)

I've compiled the NextPowerOfTwo stuff seperately and if line 192 is changed from
"Val = NextPowerOfTwo::Val" into "Val = 1" compilation succeds. This seems to indicate that
line 192 triggers the error reported on line 191.

If line 192 is changed into "Val = NextPowerOfTwo<1>::Val" I get the following error for that line:

error: incomplete type ‘NextPowerOfTwo<1u>’ used in nested name specifier

There is no other error reported: nothing about N or line 191.

@lattner
Copy link
Collaborator

@lattner lattner commented Mar 2, 2007

Does it work if you change it to:
Val = NextPowerOfTwo<(N|(N-1)) + 1>::Val

?

-Chris

@llvmbot
Copy link
Collaborator Author

@llvmbot llvmbot commented Mar 2, 2007

Yes, that works!

@lattner
Copy link
Collaborator

@lattner lattner commented Mar 2, 2007

Okay, very strange compiler bug. Easy enough to work around though:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070226/045400.html

Thanks!

BTW, I recommend downloading the latest Xcode from developer.apple.com, there are several issues with
older versions. See the Getting Started guide for details on specific broken ones.

-Chris

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla build-problem
Projects
None yet
Development

No branches or pull requests

2 participants